我有一个表单,我想根据字段 2 数据自动填充最后 2 个字段。 这是我的表格。
<form method="post">
<table> <tr><b>Add new data using form below</b></tr>
<tr><td> Keyword: </td><td> <input type="text" name="keyword" id="keyword"><br></td></tr>
<tr><td> Block?: </td><td><input type="text" name="block" id="block"><br></td></tr>
<tr><td> Phone #:</td><td> <input type="text" name="phone" id="phone"><br></td></tr>
<tr><td> Reason: </td><td> <input type="text" name="reason" id="reason"><br></td></tr>
<tr><td> </td><td align="left"> <input type="submit" name="submit" value="Submit Data"></td></tr>
</table>
</form>
因此,电话和原因将根据输入的块号自动填充。 不一定要找人来做。也许只是引导我朝着一个方向得到答案。
听起来像是jQuery的工作。尝试 #block 字段的模糊功能:
$('#block').blur(function() {
// get value, based on this, populate value of your other fields
});
http://api.jquery.com/blur/
这是在不刷新页面的情况下根据表单元素输入显示内容的方法。
将 JQuery Ajax 与 JQuery 文本框模糊事件一起使用。