I have put more than one form on my HTML page because I could layout things better that way (might have been a stupid idea...we'll soon find out).
I would like to know if there is a way to assign the submit button to send all of the forms on the page.
Forms in HTML
Started by ::WebCreate::, Jan 28 2008 10:13 AM
6 replies to this topic
#1
Posted 28 January 2008 - 10:13 AM
#2
Posted 28 January 2008 - 11:08 AM
im not sure if thats possible.. you'd have to somehow link the forms together.. Have you tried making one big form with different things in it so then you can sumbit all the information at once? Instead of two forms say just combine the two forms into one.
#3
Posted 28 January 2008 - 01:27 PM
Lastcrime, on Jan 28 2008, 12:08 PM, said:
im not sure if thats possible.. you'd have to somehow link the forms together.. Have you tried making one big form with different things in it so then you can sumbit all the information at once? Instead of two forms say just combine the two forms into one.
Yeah it will definetely work if I make one big form with everything in one, I know how to do that.
But I was kind of hoping there was a way to link the different ones I have made, to send it all at once by clicking one submit button.
Anyone else know?
#4
Posted 29 January 2008 - 09:29 PM
To the best of my knowledge, it is only possible to submit one literal form at a time, which leads back to lastcrime's idea...
You could jerry-rig an ajax "pre-submit" kind of thing... or maybe even ajax everything. But as for one press of the button taking 2 forms of data to one page simultaneously, no.
Another trick would be to "copy" the data in the different fields from one form to a type="hidden" element of the other...
Unfortunately, all of these rely on javascript. I suggest the easy way out (one big form, hopefully you don't have any sematic issues with doing that
).
You could jerry-rig an ajax "pre-submit" kind of thing... or maybe even ajax everything. But as for one press of the button taking 2 forms of data to one page simultaneously, no.
Another trick would be to "copy" the data in the different fields from one form to a type="hidden" element of the other...
Unfortunately, all of these rely on javascript. I suggest the easy way out (one big form, hopefully you don't have any sematic issues with doing that
#5
Posted 07 February 2008 - 05:52 AM
rc69, on Jan 29 2008, 09:29 PM, said:
To the best of my knowledge, it is only possible to submit one literal form at a time, which leads back to lastcrime's idea...
You could jerry-rig an ajax "pre-submit" kind of thing... or maybe even ajax everything. But as for one press of the button taking 2 forms of data to one page simultaneously, no.
Another trick would be to "copy" the data in the different fields from one form to a type="hidden" element of the other...
Unfortunately, all of these rely on javascript. I suggest the easy way out (one big form, hopefully you don't have any sematic issues with doing that
).
You could jerry-rig an ajax "pre-submit" kind of thing... or maybe even ajax everything. But as for one press of the button taking 2 forms of data to one page simultaneously, no.
Another trick would be to "copy" the data in the different fields from one form to a type="hidden" element of the other...
Unfortunately, all of these rely on javascript. I suggest the easy way out (one big form, hopefully you don't have any sematic issues with doing that
Instead I suggest you to make a good js structure! It can take you a LITTLE BIT of time, but it is much more efficent!
Having all in a big form is not a good idea.
I would assign everthing with an id and put every thing in a final form.
Here, I'll make you some functions and explain how easy it is ^^
js:
var temp = new Array();
//assignment of the forms you want in $_POST =D
function assignTMP(id)
{
temp[id] = id;
}
function submitBig(div_id,url)
{
var base = '';
var inner = document.getElementById(div_id);
//start creating all $_POST 's ^^
for(key in temp)
{
var put = document.getElementById(key).value;
base = base + '<input type="text" name="' + key + '" value="'+ put +'" />
}
//if url is defined the submit will go on the page declared, else the sam page.
if(url != false) inner.innerHTML = '<form name="banana" method="POST" action="'+ url +'">';
else inner.innerHTML = '<form name="banana" method="POST">';
// Let's stick everthing togheter!
inner.innerHTML = inner.innerHTML + base + '</form>';
//Now let's submit everthing assinged!
document.banana.submit();
}
HTML code:
<div id="div_TMP" style="visibility:hidden;display:none;"></div>
<form name="FIRST">
<input type="text" id="username" /> <input type="text" id="password" />
</form>
<form name="SECOND">
<input type="text" id="message" /> <input type="text" id="sex" />
<input type="text" id="I_DONT_NEED_THIS_INPUT" />
</form>
<script language="javascript">
// Here you declare what you want in your post!
assignTMP('username');
assignTMP('password');
assignTMP('message');
assignTMP('sex');
//as you see I didn't assign the id: I_DONT_NEED_THIS_INPUT, and it won't be shown as a post!
</script>
<input type="button" onclick="submitBig('div_TMP',false)" />
Here! Actually, you don't even need to make forms. Just put id's in your form and assign them
It may have some sintax error
Edited by communiti.ch, 07 February 2008 - 05:54 AM.
#6
Posted 07 February 2008 - 04:52 PM
I guess i forgot about that option. But now, what happens when the JS breaks?
Maybe it's just me being pessimistic, but i prefer solutions that don't rely on "optional" features.
Maybe it's just me being pessimistic, but i prefer solutions that don't rely on "optional" features.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
