【发布时间】:2015-12-29 18:48:14
【问题描述】:
我尝试在 JavaScript 中动态添加表单,但是当我单击提交按钮时没有任何反应。我知道这是因为按钮没有侦听器,但我不知道必须在侦听器中添加什么才能正常发送按钮行为。
这是我的一些代码
document.getElementById("partTwo").innerHTML += "<form id='download_report' method='post' class='form-horizontal' role='form' action='include/client.process.php'>";
document.getElementById("partTwo").innerHTML += "<input type='hidden' name='jobid' value='" + jobId + "'/>";
document.getElementById("partTwo").innerHTML += "<input type='hidden' name='job' value='" + job_details.heavyInfosJson + "'/>";
document.getElementById("partTwo").innerHTML += "<input type='hidden' name='download_report' value='1'/>";
document.getElementById("partTwo").innerHTML += "<button id='download_report_button' type='submit' class='btn btn-default btn-xs'>Télécharger le rapport</button>";
document.getElementById("partTwo").innerHTML += "</form>";
我希望听众将表格发送到我的client.process.php
我知道这是一个初学者问题,但我们将不胜感激。 谢谢
【问题讨论】:
标签: javascript forms button listener