dream04110 2016-02-12 02:03
浏览 589

页面自动刷新后不会发生表单重置

I have a Iframe which has a form with text fields.This form is created by php script. The parent page refresh auto, continuously.

<form id="form"  method="post" action="test.php?vid='.$vid.'">
<table border="1" width="100%"  style="border-collapse:collapse">
<tr>
<th class="col-header list">Distance </th>
<th class="col-header list">Service</th>
<th class="col-header list">Recipient</th>
</tr>
<tr>
<td >
<input type="text" class="input" id="cdistance" name="cdistance" />
</td>
<td nowrap class="list">
<input type="text" class="input" id="service" name="service" />
</td>
<td nowrap class="list">
<input type="text" class="input" id="destination" name="destination" />
</td>
</tr>
<tr>
<td width="100%" colspan="3" style="background:#e0e0e0;">
<input type="submit" class="btn" name="add" id="add" value="Add New"/>
<input type="hidden" name="distance_unit" value="'.$distance.'" />
</td>
</tr>
</table>
</form>

To avoid user entered data loosing ('before hit submit') I used query code in parent page to get those entered text in Iframe's form and add them back to text fields after page refreshed.

My problem is when the user hit the submit button after page refreshed text fields are not cleared (form not reset) but data submitted successfully.So I tried to reset the form by $('#form')[0].reset(). This is the error I got

Uncaught TypeError: Cannot read property 'reset' of undefined

Also tried $('#textVal').val(''); to empty text fields. But still the data remaining in text fields.

Note: The form is reset if the user hit submit button before refreshed. Does anyone need more details please let me know.

Any solution for this would be appreciated.

  • 写回答

2条回答 默认 最新

  • doupian9798 2016-02-12 02:23
    关注

    Try

    $('#form').trigger("reset");
    
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大