Javascript 如何在jquery中获取jsp生成的动态表单id
如何使用jquery获取通过使用jsp生成的formIdJavascript 如何在jquery中获取jsp生成的动态表单id,javascript,jquery,html,jsp,Javascript,Jquery,Html,Jsp,如何使用jquery获取通过使用jsp生成的formId <c:url var="updateSubUserDetails" value="/employer/recruiters/updateSubUserDetails"/> <form id="updateform${subUser.employerId}" action="${updateSubUserDetails}" method="post" > <div class="modal-body"&g
<c:url var="updateSubUserDetails" value="/employer/recruiters/updateSubUserDetails"/>
<form id="updateform${subUser.employerId}" action="${updateSubUserDetails}" method="post" >
<div class="modal-body">
<input type="hidden" name="subUserId" value="${subUser.employerId}"/>
<div class="form-group">
<input type="text" id="subUserName${subUser.employerId}" name="subUserName" class="form-control " value="${subUser.firstName}" placeholder="Edit Sub User Name"/>
</div>
<div class="form-group">
<input type="text" id="subUserEmail${subUser.employerId}" name="subUserEmail" class="form-control " value="${subUser.emailId}" onchange="checkMail(${subUser.employerId})" placeholder="Edit Email"/>
</div>
<span id="avialabilityMessage${subUser.employerId}"></span>
<div class="form-group">
<input type="text" id="subUserMobile${subUser.employerId}" name="subUserMobile" class="form-control " value="${subUser.mobileNumber}"placeholder="Edit Contact No"/>
</div>
<sec:csrfInput/>
<div class="modal-footer">
<input type="button" id="muEditButtonID" onclick="updateSubUserDetails(${subUser.employerId})" class="btn btn-warning btn-lg glyphicon glyphicon-ok-sign" value="Update">
</div>
</div>
</form>
如何在JavaScriptjQuery中获取上述动态生成的表单id?请帮助我
//if you sure there is only one form
document.forms[0]
//else
document.querySelector('[id^="updateform"]')
所以,如果你想获得id,只需添加.id
//if you sure there is only one form
document.forms[0].id
//else
document.querySelector('[id^="updateform"]').id
你想在
updateSubUserDetails
函数中使用它吗?document.querySelector('[id^=“updateform”]')
?改进的代码格式。请发布你当前拥有的任何代码。我有多个具有不同id的表单,例如:updateform120,updateform121…..等等,我如何获取动态生成的formId。您需要获取所有表单的id,还是只获取一个?或者您想通过id获取表单元素?document.querySelectorAll('[id^=“updateform”]')-这将返回一组id为的节点元素,如您上面所述。如何获取实际的formId,因为所有ListofForms将为您提供所有idvar forms=document的数组。querySelectorAll('[id^=“updateform”]),id=[];对于(var i=0;i
我如何在该列表中获取(我将提交)特定的formId