问题
I have TWO forms on my website.
Is it possible when I submit one of these, it will take form data from a particular field in the other form?
I am using the Recurly system with PHP.
回答1:
You can write your own function.
function submit (){
document.getElementById("firstform").submit();
document.getElementById("secondform").submit();
}
You can then make a button that calls this function.
If this doesn't work, try again using ajax. Example
回答2:
You can do it with javascript.
For example:
var request =false;
function submit()
{
var yourobject = document.getElementById("yourobject").value;
data = "yourobject" + "=" + encodeURIComponent(yourobject);
request.open("POST", "yourpage.php", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send(data);
}
And the input:
<input type="button" onclick="submit()" value="Submit" />
来源:https://stackoverflow.com/questions/19785198/two-forms-one-submit-button