日期:2014-05-16  浏览次数:20369 次

关于JS清空当前循环中的INPUT
<script type="text/javascript">
function clearText() {
  document.getElementById("visitor_c_name").value = "";
  document.getElementById("visitor_e_name").value = "";
  document.getElementById("papers_id").value = "";
  document.getElementById("m_phone").value = "";
  return false;
}
</script>
{foreach from=$visitor_list item=visitor_item}
<table width="956" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td width="111" scope="col">&nbsp;</td>
  <td width="142" scope="col">&nbsp;</td>
  <td width="132" scope="col">&nbsp;</td>
  <td width="100" scope="col">&nbsp;</td>
  <td width="367" scope="col">&nbsp;</td>
  <td width="104" scope="col">&nbsp;</td>
  </tr>
  <tr>
  <td height="30">&nbsp;</td>
  <td align="left">第{$visitor_item.id}位游客</td>
  <td colspan="4" align="left"><a onclick="clearText({$visitor_item.id})" >[清空]</a></td>
  </tr>
  <tr>
  <td height="30">&nbsp;</td>
  <td align="right">中文姓名:</td>
  <td colspan="4"><input maxlength="50" name="visitor_c_name[]" id="visitor_c_name{$visitor_item.id}" size="40" type="text" value=""></td>
  </tr>
  <tr>
  <td height="30">&nbsp;</td>
  <td align="right">英文姓名:</td>
  <td colspan="4"><input maxlength="50" name="visitor_e_name[]" id="visitor_e_name{$visitor_item.id}" size="40" type="text" value="" /></td>
</tr>
<tr>
  <td height="30">&nbsp;</td>
  <td align="right">手机:</td>
  <td colspan="4"><input maxlength="50" name="m_phone[]" id="m_phone{$visitor_item.id}" size="40" type="text" value="" /></td>
  </tr>
</table>
{/foreach}
清空只需清空当前循环内指定的INPUT的值
请问该怎么写JS啊?麻烦大虾们帮忙看下。

------解决方案--------------------
探讨

<a href="#" onclick="return clearText({$visitor_item.id})" >[清空]</a>


function clearText(id) {
document.getElementById("visitor_c_name"+ id).value = "";
document.getElementById("visitor_e_n……