[英]How to return id of a submitted form using Prototype?
我的頁面有幾個ajax提交表單。 每個表單在寫入頁面時都會分配一個動態ID。 有誰知道是否有一種簡單的方法來返回正在提交的表單的ID? 我基本上是想點擊“提交”並提醒所提交表單的ID。 從那里,我可以在ajax onSuccess函數中使用它。
我建議您在onsubmit
事情中從表單中檢索它:
<form action="/npup.do" name="foo" id="generated_4321" onsubmit="npup(this);">
[...]
</form>
<script type="text/javascript">
function npup(form) {
form = $(form);
var formIdInput = new Element('input', {type:'hidden', name:'formId', value:form.id});
form.append(formIdInput);
}
</script>
如果您只想在提交時檢索表單的ID值,則只需從onsubmit中的form元素獲取它(如上),然后執行使<div>
浮動的任何操作,而不是像我一樣將其推入表單。
嗯,在PHP杯中有一種方法可以引用生成的表單嗎? 在.NET中,您可以執行以下操作:
$('#<%MyForm.ClientId %>')
這將返回正在呈現的表單或控件的客戶端ID。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.