To submit a form or not to submit a form?
Tuesday, 20. June 2006, 15:05:40
Making the searchbox for the toolbar I found some anoying problems with styling buttons, submiting to multiple locations and opening links with javascript.
I thought the below was an interesting way to submit a form. One can use ordinary links for "submit" use 100 submit buttons and use a normal link to submit.
function zap(zz){
var thestring = document.getElementById('q').value
if (thestring != ""){
if (zz=="google")
{
document.getElementById(zz).href = "http://www.google.com/search\?client=opera&rls=en&q="+thestring+"&sourceid=opera&ie=utf-8&oe=utf-8"
}
else if (zz=="images")
{
document.getElementById(zz).href = "http://images.google.com/images\?client=opera&rls=en&q="+thestring+"&sourceid=opera&oe=UTF-8&ie=UTF-8&sa=N&tab=wi"
}
else if (zz=="gmail")
{
document.getElementById(zz).href = "http://gmail.google.com/gmail\?search=query&view=tl&start=0&init=1&fs=1&q="+thestring
}
}
}
the form would look something like this:
<form action="http://google.com/search" method="GET">
<input type="text" id="q" name="q" size="5" maxlength="255" value="" />
</form>
and the submit linkS looks like this:
<a id="google" onmousedown="zap('google');" href="http://google.com/">
<img src="images/favicon.gif" alt="Google">
</a>
If the text box is empty the normal link wil be opend, and if enter is pressed the search will be submitted.
Now I want to expand it a bit.
I thought the below was an interesting way to submit a form. One can use ordinary links for "submit" use 100 submit buttons and use a normal link to submit.
function zap(zz){
var thestring = document.getElementById('q').value
if (thestring != ""){
if (zz=="google")
{
document.getElementById(zz).href = "http://www.google.com/search\?client=opera&rls=en&q="+thestring+"&sourceid=opera&ie=utf-8&oe=utf-8"
}
else if (zz=="images")
{
document.getElementById(zz).href = "http://images.google.com/images\?client=opera&rls=en&q="+thestring+"&sourceid=opera&oe=UTF-8&ie=UTF-8&sa=N&tab=wi"
}
else if (zz=="gmail")
{
document.getElementById(zz).href = "http://gmail.google.com/gmail\?search=query&view=tl&start=0&init=1&fs=1&q="+thestring
}
}
}
the form would look something like this:
<form action="http://google.com/search" method="GET">
<input type="text" id="q" name="q" size="5" maxlength="255" value="" />
</form>
and the submit linkS looks like this:
<a id="google" onmousedown="zap('google');" href="http://google.com/">
<img src="images/favicon.gif" alt="Google">
</a>
If the text box is empty the normal link wil be opend, and if enter is pressed the search will be submitted.
Now I want to expand it a bit.














How to use Quote function: