Forums
This topic is locked
Is it possible to have a form within a form?
23 Apr 2004 18:44:09 Jon McGee posted:
Is it possible to have a form within a form? but have them action to different pages, i.e. button 1 in form one goes to page A whereas button 1 in form 2 (a child of form 1) goes to page Z. I cant seem to get it to work, it always goes to page A no matter which button I hit.On my page www.bioscience.co.uk/New/search_layers5.asp I have a search form surrounding the whole page and submits to itself.
Now when you do a search and click on a result the detail appears. In the detail section a 'save details/order this product' button appears. Now this is in a separate form and needs to redirect to a different page as its transporting UltraCart shopping variables, but the page just resubmits to itself, even though its told different.
Here's the order button form header:form action="< %=UC_editAction% >" method="POST" name="details" where the UC_editAction is defined elsewhere in the scripts.
Thanks
<pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code><b></b><b></b><b></b><b></b> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code>
Replies
Replied 23 Apr 2004 20:03:51
23 Apr 2004 20:03:51 Dave Thomas replied:
<pre id=code><font face=courier size=2 id=code>
<script language="JavaScript">
<!--
function submitForm()
{
document.Form1.action = "pageA.asp" // replace the main form action here
document.Form1.submit(); // Submit the page
return true;
}
function submitForm2()
{
document.Form2.action = "pageZ.asp"; // replace your child form action here
document.Form2.submit(); // Submit the page
return true;
}
-->
</script>
</font id=code></pre id=code>
you'll just need to make sure Form1 & Form2 are changed to your form names, Form 1 being the parent, Form2 being the child
FORM 1:
<pre id=code><font face=courier size=2 id=code>
<form name="Form1" id="Form1" method="post">
// your form code
<INPUT type="button" value="Submit1" name="submit" onclick="return submitForm();">
</form>
</font id=code></pre id=code>
FORM 2:
<pre id=code><font face=courier size=2 id=code>
<form name="Form2" id="Form2" method="post">
// your form 2 code
<INPUT type="button" value="Submit2" name="submit" onclick="return submitForm2();">
</form>
</font id=code></pre id=code>
Leave your form actions blank, and replace them in the javascript code above where commented.
Regards,
Dave
[DWMX 2004]|[FlashMX 2004 Pro]|[Studio MX 2004]|[SQL]|[Access2000/2002]|[ASP/VBScript]|[XP-Pro]
If you like online gaming, please register @ www.nova-multigaming.com
<script language="JavaScript">
<!--
function submitForm()
{
document.Form1.action = "pageA.asp" // replace the main form action here
document.Form1.submit(); // Submit the page
return true;
}
function submitForm2()
{
document.Form2.action = "pageZ.asp"; // replace your child form action here
document.Form2.submit(); // Submit the page
return true;
}
-->
</script>
</font id=code></pre id=code>
you'll just need to make sure Form1 & Form2 are changed to your form names, Form 1 being the parent, Form2 being the child
FORM 1:
<pre id=code><font face=courier size=2 id=code>
<form name="Form1" id="Form1" method="post">
// your form code
<INPUT type="button" value="Submit1" name="submit" onclick="return submitForm();">
</form>
</font id=code></pre id=code>
FORM 2:
<pre id=code><font face=courier size=2 id=code>
<form name="Form2" id="Form2" method="post">
// your form 2 code
<INPUT type="button" value="Submit2" name="submit" onclick="return submitForm2();">
</form>
</font id=code></pre id=code>
Leave your form actions blank, and replace them in the javascript code above where commented.
Regards,
Dave
[DWMX 2004]|[FlashMX 2004 Pro]|[Studio MX 2004]|[SQL]|[Access2000/2002]|[ASP/VBScript]|[XP-Pro]
If you like online gaming, please register @ www.nova-multigaming.com
Replied 26 Apr 2004 16:42:31
26 Apr 2004 16:42:31 Jon McGee replied:
Hi thanks again for you help. Umm, ive tried implementing the scripts but its still not redirecting to the correct page. It's still redirecting to itself. Here's my code: <pre id=code><font face=courier size=2 id=code> <script language="JavaScript">
<!--
function
submitForm()
{
document.mainsearch.action = "search_layers6.asp"
document.mainsearch.submit();
return true;}
function submitForm2()
{
document.details.action = "orderbook.asp>";
document.details.submit(); return true;}--></script> </font id=code></pre id=code>
and
<pre id=code><font face=courier size=2 id=code> <form name="mainsearch" id="mainsearch" method="post">
<input name="image" type="image" value="Click here" src="search.gif" onclick="return submitForm();"></font id=code></pre id=code>
and <pre id=code><font face=courier size=2 id=code>
<form name="details" id="details" method="POST"> <input type="image" src="addtoorder.gif" name="image"
onclick="return submitForm2();"></font id=code></pre id=code>
Update: Ive even changed the .asp pages to completely different ones that i actually want to redirect to and the form still redirects to itself on the same page.
Edited by - jonny mags on 26 Apr 2004 18:32:51
<!--
function
submitForm()
{
document.mainsearch.action = "search_layers6.asp"
document.mainsearch.submit();
return true;}
function submitForm2()
{
document.details.action = "orderbook.asp>";
document.details.submit(); return true;}--></script> </font id=code></pre id=code>
and
<pre id=code><font face=courier size=2 id=code> <form name="mainsearch" id="mainsearch" method="post">
<input name="image" type="image" value="Click here" src="search.gif" onclick="return submitForm();"></font id=code></pre id=code>
and <pre id=code><font face=courier size=2 id=code>
<form name="details" id="details" method="POST"> <input type="image" src="addtoorder.gif" name="image"
onclick="return submitForm2();"></font id=code></pre id=code>
Update: Ive even changed the .asp pages to completely different ones that i actually want to redirect to and the form still redirects to itself on the same page.
Edited by - jonny mags on 26 Apr 2004 18:32:51