PDA

View Full Version : three actions 1 form



utoronto-guy
Mar 19th, 2007, 10:34 PM
I believe what i need is one form, and three actions.

Below is my form. I do not have a <form> tag wrapping it and you will see why in my JS to follow.


<input name="q" id="q" onfocus="javascript: googlehasfocus=this;" onkeydown="javascript: if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {SubmitGoogleForm();};" size="20" maxlength="255" type="text" class="textfield" />
<input name='googlesearchbutton' type="button" id='googlesearchbutton' onclick="javascript: googlehasfocus=this; SubmitGoogleForm();" value="Go" class="button-search" />
<input type="radio" value="http://www.arts.utoronto.ca" name="as_sitesearch" checked />This Site&nbsp;
<input type="radio" value="" name="as_sitesearch" />UToronto<br />
<input type="radio" value="google" name="as_sitesearch" />Google
<input type="hidden" name="output" value="xml_no_dtd" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="oe" value="UTF-8" />
<input type="hidden" name="client" value="default_frontend" />
<input type="hidden" name="proxystylesheet" value="default_frontend" />
<input type="hidden" name="site" value="default_collection" />


So here is the JS i am trying to use to submit the info and select the proper output.


function radioSelected(radios) {
for (i=0;i<radios.length;i++) {
if (radios[i].checked) {
return radios[i].value;
}
}
return '';
}
var siteVal = radioSelected(document.forms[0].radios);

var googlehasfocus

function SubmitGoogleForm()
{
if (googlehasfocus){
if (googlehasfocus.name=='q' || googlehasfocus.name=='googlesearchbutton')
{
if (null != document.forms[0].__VIEWSTATE) {document.forms[0].__VIEWSTATE.name='NOVIEWSTATE';}
if (siteVal == "this_site") {
document.forms.item('IronPointForm').method='get';
document.forms.item('IronPointForm').action='http://find.utoronto.ca/search';
document.forms.item('IronPointForm').submit();
}
if (siteVal == "utoronto") {
document.forms.item('IronPointForm').method='get';
document.forms.item('IronPointForm').action='http://find.utoronto.ca/search';
document.forms.item('IronPointForm').submit();
}
if (siteVal == "google") {
window.location ="http://www.google.ca/search?"+q;
}
}
}
};

Can someone help me? The reason i have to use Javascript is because our servers do not support PHP or ASP or any scripting besides javascript.

Thanks
Chad :confused:

shyam
Mar 19th, 2007, 11:10 PM
if u don't have a form what are u trying to submit?