English 中文(简体)
我如何提交一种形式,没有任何形式的身份证,没有提交身份证,而是已知的隐藏价值?
原标题:How do I submit a form with no form ID and no submit ID, but known hidden value?

the situation I m struggling with is that there are more forms on the page that looks like this (the hiddenId is different in each form):

<form method="post">
<input type="hidden" name="hiddenId" value="111222">
<input type="submit" value="Proceed">
</form>

<form method="post">
<input type="hidden" name="hiddenId" value="111333">
<input type="submit" value="Proceed">
</form>

我如何用javascript(我不使用jQuery)提交具体形式,包括隐蔽的表格 理想价值吗? 感谢你的帮助!

最佳回答

根据这些思路,你应开始:

var inputs = document.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++) {
    if(inputs[i].type === "hidden" && inputs[i].value === "111333") {
        inputs[i].form.submit();
    } 
}

如果你能够使用 j子:

$("input[type= hidden ][value= something ]").closest("form").submit();
问题回答

文件:格式是一个阵列,document.forms[0]是第一个。

内容同样:

<代码>文件.forms[0].elements[0]. Value/code>等

在您提交现有表格之前,您可以选择:

document.forms[x].submit()

使用<条码>所有表格查阅:文件格式;

loop through them as needed to access inputs

您可使用https://developer.mozilla.org/En/DOM/Document.querySelector” rel=“nofollow”.querySelector。 或各种Java图书馆之一在旧浏览器上播映,以找到隐藏的输入要素,然后使用其<代码>form 的财产进入表格并援引<代码><>submit>/code>方法。

您可以补充表格,提交纽伦:

<form method="post" id="form1">
<input type="hidden" name="hiddenId" value="111222">
<input type="submit" value="Proceed" id="submit1">
</form>

<form method="post" id="form2">
<input type="hidden" name="hiddenId" value="111333">
<input type="submit" value="Proceed" id="submit2">
</form>

然后,用 j子提交表格:

$("#submit1").click(function() {
    form1.submit();
}
$("#submit2").click(function() {
    form2.submit();
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签