简体   繁体   English

HTML表单提交问题

[英]HTML form submit issues

Brand new to HTML, I have experience programming in other languages, just having an issue with html. 对HTML来说是全新的,我有使用其他语言进行编程的经验,只是对html有问题。
I've looked around to try to find a way to have a "double post" in html that posts all of instances needed. 我环顾四周,试图找到一种方法来在html中发布一个“双重发布”,以发布所需的所有实例。

The reason why i need the multiple forms as of now, is because the outer code takes in sales information, and the moves through an authorize page, but i can only get one or the other to trigger. 到目前为止,之所以需要多种形式的原因是,外部代码吸收了销售信息,并通过了一个授权页面,但是我只能触发其中一个。

    <form method="post" action="sales_info_driver_page.cgi">

    Outer code here
    </form>
    <form method="POST" action="http://www.example.com/su.php"><p>
    <input type="text"  name="Email" size="20"><br>
    <input type="radio" name="Action" value="join-list" checked>Subscribe </p>
    <input type="hidden" name="ThanksURL" value="2222">
    </form>

    Outer code here

    <input type="submit" name="Submit" value="   Submit   " >

Is it even possible for the inner form to be submitted via either a javascript function or some other means? 内部表格是否有可能通过javascript函数或其他某种方式提交? i read that it is not very plausable to have nested forms, so is there another way to have this section submit properly? 我读到嵌套表格不是很合理,所以是否有另一种方法可以使此部分正确提交?

Need by 12-5-12 if at all possible! 如果可能的话,需要在12-5-12之前! Thanks ahead of time! 提前谢谢!

It's bad practice to have multiple forms nested inside other forms, as it is invalid HTML... 无效的做法是在其他表单中嵌套多个表单,因为它是无效的HTML ...

If you want to submit a form from a link outside the form, just give the form an ID such as: <form method="POST" action="http://www.example.com/su.php" id="form1"> and add the submit button back into the parameters of the <form> . 如果要通过表单外部的链接提交表单,只需给表单提供一个ID,例如: <form method="POST" action="http://www.example.com/su.php" id="form1">并将提交按钮添加回<form>的参数中。

Then, wherever you want to submit the form, you can use a javascript handler: 然后,无论您要提交表单的何处,都可以使用javascript处理程序:

eg: <a href="#" onclick="document.getElementById('form1').submit();">Submit Form1</a> 例如: <a href="#" onclick="document.getElementById('form1').submit();">Submit Form1</a>

Of course, it's better practice to use functions and not bind inline event handlers, but this is just an example and to demonstrate the use of onclick and form submission. 当然,更好的做法是使用函数而不绑定内联事件处理程序,但这只是一个示例,并演示了onclick和表单提交的用法。

If you're using jQuery, you can just do: onclick="$('#form1').submit();" 如果您使用的是jQuery,则可以执行以下操作: onclick="$('#form1').submit();" , which is much simpler. ,这要简单得多。

I suppose it's possible to adapt the above method to submit all of the forms; 我想可以采用上述方法来提交所有表格。 and you can use jQuery/Javascript to find and collect all the values that you want to submit when the button is clicked, then use an Ajax call to send all the values to one destination. 您可以使用jQuery / Javascript查找并收集单击按钮时要提交的所有值,然后使用Ajax调用将所有值发送到一个目的地。

instead using form, you may used div for divisions of it 而不是使用形式,您可以使用div进行划分

<form method="POST" action="http://www.example.com/su.php">
<div>

Outer code here
</div>
<div><p>
<input type="text"  name="Email" size="20"><br>
<input type="radio" name="Action" value="join-list" checked>Subscribe </p>
<input type="hidden" name="ThanksURL" value="2222">
</div>

Outer code here

<input type="submit" name="Submit" value="   Submit   " >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM