我试图从动态生成的表单中提醒我捕获的表单数据。
<body>
<div id="main1">
<input type="button" onclick="addSelectBox ()" name="clickme" value="+" />
<input type="button" onclick="removeSelect();" value="-" />
<input type="button" onclick="xmlData();" value="XML" />
</div>
<form id="autoPopulation_form" method='post'>
<div id="main"></div>
<input type="submit" />
</form>
</body>
但是它在 JSFiddle 上失败并出现此错误:
{"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0x3e29f50>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', 'label': u'Js lib', 'field': <django.forms.models.ModelChoiceField object at 0x3f33f50>, 'help_text': '', 'name': 'js_lib'}{'html_initial_name': u'initial-js_wrap', 'form': <mooshell.forms.ShellForm object at 0x3e29f50>, 'html_name': 'js_wrap', 'html_initial_id': u'initial-id_js_wrap', 'label': u'Js wrap', 'field': <django.forms.fields.TypedChoiceField object at 0x3f33c10>, 'help_text': '', 'name': 'js_wrap'}"}
任何人都可以帮我吗,我正在尝试查看我的所有表单数据
最佳答案
您有语法错误。它应该是 document.getElementById
而不是 document.getElementByid
。
window.onload = function () {
document.getElementById('autoPopulation_form').onsubmit = function () {
var frmData = new FormData(this);
alert(frmData);
// return false; // uncomment this if you don't want the form to actually be submitted.
};
};
编辑: 显然,“onSubmit”也应该更改为“onsubmit”。
关于javascript - 无法提醒 formdata onSubmit(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22325148/