Click to See Complete Forum and Search --> : Two actions - One Submit
amit_tgo
03-19-2004, 11:26 PM
Hello,
Am looking at
one submit button with either one textbox or two,
that will submit data to two forms with two different actions.
action="1.asp" action="2.asp"
Or submit to two actions action="1.asp" action="2.asp" in one form with one submit button.
Help Help Help!
Regards
Amit
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function subm(){
document.forms[0].submit();
document.forms[1].submit();
}
</script>
</head>
<body>
<form action="1.asp" method="post"></form>
<form action="2.asp" method="post"></form>
<input type="button" value="Submit" onclick="subm()">
</body>
</html>
Or this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function subm(){
document.forms[0].submit();
return true
}
</script>
</head>
<body>
<form action="1.asp" method="post"></form>
<form action="2.asp" method="post" onsubmit="return subm()">
<input type="submit">
</form>
</body>
</html>
amit_tgo
03-20-2004, 02:43 AM
Hi Kor,
Am confused.
I checked the code and it seems as if the value would be passed onto both urls.
But i have set cookies on both 1.asp and 2.asp, so if whenever they are called, they will create cookies through which i could recognize if they are called or not.
However, the problem seems to be that 1.asp isnt creating the cookie. whereas 2.asp is creating the cookie.
Also on submit, it simply processes 2.asp but i havent seen it process 1.asp too.
Any clue as to whats actually going on ?
I need 1.asp to be called as well
Thanks & Regards
Amit
I checked the code and it seems as if the value would be passed onto both urls.
They should not. In first case, the button is a simple button, not a type=submit. Anyway, it is placed outside the forms, so it is not a form's element.
Second case th button is a submit one, it will automatically submit the form it is placed inside, but I hoped that it might call the function, submit the first form, than is return true, will sumbit his own form.
Well, It might not work from other reason. You might need a single HTTP to action a post, so here's is another solution, use iframes. Put your second form in an iframe (if border 0, noone will see that there is an iframe). Now, onclick a simple button on parent (like in my first example), call a function like:
function subm(){
document.forms[0].submit();
top.frames[0].document.forms[0].submit();
}
amit_tgo
03-20-2004, 03:30 AM
Hi Kor,
The Iframe idea sounds very appealing and i guess it should work.
But am a total :(
Could you pls make a sample code of the same.
I hope its not too much of a trouble.
Regards
Amit
parent.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function subm(){
top.frames[0].document.forms[0].submit();
document.forms[0].submit();
}
</script>
</head>
<body>
<form method="post" action="1.asp">
<input name="one" type="text">
</form>
<iframe src="iframe.html" frameborder="NO" border="0" framespacing="0" noresize></iframe>
<input type="button" value="Submit" onclick="subm()">
</body>
</html>
iframe.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form method="post" action="2.asp">
<input name="two" type="text">
</form>
</body>
</html>
See also attachment
amit_tgo
03-20-2004, 11:22 PM
Thank You
Have a nice Day KOR
Regards
Amit