Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple actions in one form

Status
Not open for further replies.

AKS44

Programmer
Feb 7, 2006
20
0
0
US
I am trying to incorporate two search forms into one form. I am assuming that it will require some java scripting to accomplish this. However, i am not sure how to do this; any and all help would be greatly appreciated.

Incorporate form 2 with form 1

Form 1 -

<FORM method=GET action= <TABLE bgcolor=#FFFFFF cellspacing=0 border=0>
<tr valign=top><td>
<A HREF= </td>
<td>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof
VALUE="GIMP:black;T:black;LW:780;ALC:red;L: <font face=arial,sans-serif size=-1><input type=hidden name=domains value=" type=radio name=sitesearch value="pcl.lib.wa.us" checked>
Search Our Site</font></td>
</tr></TABLE>
</FORM>

Form 2 -

<form method="GET" action=" id="simple" name="simple" onsubmit="return validatequicksearch();">
<input type="text" name="term" id="term" size="25">
<input name="ctx" type="hidden" value="1.1033.0.0.1">
<input name="type" type="hidden" value="keyword">
<input name="by" type="hidden" value="KW">
<input name="sort" type="hidden" value="PD">
<input name="query" type="hidden" value="">
<input name="page" type="hidden" value="0"><br>
<input type="submit" value="Go!" name="btnSearch">
<input type='reset' value="Reset Form" id='reset' name='reset'>
</form>
 
Which action do you want to use? How can one page go to 2 different URLs at the same time?

With the GET method, you could open a separate window and send the information that way, which would work except for the LARGE percentage of people who have a popup blocker.

Another suggestion would be to submit to one URL, then have that URL send the form element data to the next URL you want to submit to.

Lee
 
we here is what i have come up with thus far. Maybe this will clear up some question.

<!-- create the form -->
<form name=Form1 method=post>

<!-- Add the data entry bits -->
Your Name <INPUT type="text" name=text1>
<input type=image name=sa value="Search" src="/images/btn_go.gif" width="25" height="25" />
<br>

<!-- Add some buttons -->
<input type="radio" name="sitesearch" value="pcl.lib.wa.us" checked />
Library
<input type="radio" name="sitesearch" value="polariscatalog.pcl.lib.wa.us/Polaris/">
Catalog
<!-- close the form -->
</form>

<PRE><script language=javascript>
<!--
function OnButton1()
{
document.Form1.action = " document.Form1.target = "_self"; // Open in a new window
document.Form1.submit(); // Submit the page
return true;
}

function OnButton2()
{
document.Form1.action = "PAge2.asp"
document.Form1.target = "_self"; // Open in a new window
document.Form1.submit(); // Submit the page
return true;
}
-->
</script>
<noscript>You need Javascript enabled for this to work</noscript>
</PRE>
 
There's something ironic about a web page that has some of the XHTML />s added (not all, though), but most of the attributes aren't enclosed in quotes, some tags are capitalized, and the script tag isn't complete. Kinda like mixing Volkswagen Beetle parts with Ferrari parts, if you know what I mean.

Anyway, try the following and see how that works.
Code:
<form name="Form1" method="post" onsubmit="return setaction();">

<!-- Add the data entry bits -->
Your Name <input type="text" name=text1 />
<input type="image" name="sa" value="Search" src="/images/btn_go.gif" width="25" height="25" />
<br />

<!-- Add some buttons -->
<input type="radio" name="sitesearch" value="pcl.lib.wa.us" checked="checked" /> &nbsp; Library<br />
<input type="radio" name="sitesearch" value="polariscatalog.pcl.lib.wa.us/Polaris/" /> &nbsp; Catalog<br />
<input type="submit" value="Submit" />
<!-- close the form --> 
</form>

<script language="javascript" type="text/javascript">
<!--

function setaction()
{
var thisform = document.forms['Form1']
var radiobutton=thisform.elements['sitesearch'];

for (var ri=0;ri<radiobutton.length;ri++)
  {
  if (radiobutton[ri].checked)
    {
    thisform.action = radiobutton[ri].value;
    thisform.target = '_self';
    return true;
    }
  }
return false;
}

-->
</script>

This is set up to handle any number of choices, not just the 2 you show here, and also allow for NONE of the radio buttons to be selected (will not submit if that's the case, with the return false; at the end of the function).

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top