我是php的新手。我想执行表格级联 我将使用注册表格,如果我在文本字段中输入任何数据,它应该在单击提交按钮之前自动以另一种形式显示。
如果有人知道帮助我,请 我有需要。
答案 0 :(得分:1)
一点点Javascript就可以了。如果您使用jQuery之类的东西来帮助您,那将很容易。只需使用change()方法将表单中的每个字段绑定到更改事件,然后将“级联”字段更新为传递给change()方法的值。
例如,考虑HTML:
<form>
<input type="text" id="field1" />
<input type="submit" />
</form>
并且假设您要在编辑上述表单时动态更新以下div:
<div id="field1_val"></div>
将以下脚本添加到HTML的开头:
//This will just make sure you're using the awesomeness of jQuery...
<script src="http://code.jquery.com/jquery-latest.js"></script>
//This will bind your field to the change event using jQuery
<script type="text/javascript">
$("#field1").change( function() {
$("#field1_val").text($(this).val());
});
</script>
希望指出你正确的方向。