470,602 Members | 1,614 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

Form Script Help

Sev
Website: www.flywessex.blogspot.com

You can see from the page source what an effin' mess I'm making of the
site. Aside from all the obvious alignment issues, I can't get the code
to link to the web pages within the pop up boxes. They did a minute
ago, and now I've been editing the template, they don't.

Sorry if I have not supplied enough information - but I know nothing.
Anything I've done has been from searching google and copying code.

Please help.
Jul 23 '05 #1
2 1199
Sev wrote:
Website: www.flywessex.blogspot.com

You can see from the page source what an effin' mess I'm making of the
site. Aside from all the obvious alignment issues, I can't get the code
to link to the web pages within the pop up boxes. They did a minute
ago, and now I've been editing the template, they don't.

Sorry if I have not supplied enough information - but I know nothing.
Anything I've done has been from searching google and copying code.

Please help.


Hi Sev,

:) Fortunately your problem is very easy to fix.

Below is a snippet of javascript and html from your site:

<form name = "INTERVIEWS">
<select name="site" size=1>
<option value="">Click to select</option>
<option value="http://some page.html">text
</select><br><br>
<input type=button value="Go!" onClick="javascript:formHandler(this)">
</form>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function formHandler(form){
var URL =
document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</SCRIPT>

Sev, here is a more "correct" way of doing it. For your forms write
them out like so:

<form name = "abc" onSubmit = "return formHandler(this)">
<select name = "site" size = "1">
<option value = "http://value1">text 1</option>
<option value = "http://value2">text 2</option>
</select>
<input type = "submit" value = "Go!">
</form>

For your javascript portion, it would be better if you moved it into
the <head></head> section of your html, and rewritten like so:

<script language = "javascript" type = "text/javascript">
<!--
function formHandler(myForm)
{
var URL = myForm.site.options[myForm.site.selectedIndex].value;
window.location.href = URL;

return false;
}
//-->
</script>

The problem with your current script is you have your input button call
formHandler with "this". But "this" is really a reference to the input
button, and not the form that you were hoping for. Hope this helps. :)

Jul 23 '05 #2
Sev
web.dev wrote:
Sev wrote:
Website: www.flywessex.blogspot.com

You can see from the page source what an effin' mess I'm making of the
site. Aside from all the obvious alignment issues, I can't get the code
to link to the web pages within the pop up boxes. They did a minute
ago, and now I've been editing the template, they don't.

Sorry if I have not supplied enough information - but I know nothing.
Anything I've done has been from searching google and copying code.

Please help.

Hi Sev,

:) Fortunately your problem is very easy to fix.

Below is a snippet of javascript and html from your site:

<form name = "INTERVIEWS">
<select name="site" size=1>
<option value="">Click to select</option>
<option value="http://some page.html">text
</select><br><br>
<input type=button value="Go!" onClick="javascript:formHandler(this)">
</form>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function formHandler(form){
var URL =
document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</SCRIPT>

Sev, here is a more "correct" way of doing it. For your forms write
them out like so:

<form name = "abc" onSubmit = "return formHandler(this)">
<select name = "site" size = "1">
<option value = "http://value1">text 1</option>
<option value = "http://value2">text 2</option>
</select>
<input type = "submit" value = "Go!">
</form>

For your javascript portion, it would be better if you moved it into
the <head></head> section of your html, and rewritten like so:

<script language = "javascript" type = "text/javascript">
<!--
function formHandler(myForm)
{
var URL = myForm.site.options[myForm.site.selectedIndex].value;
window.location.href = URL;

return false;
}
//-->
</script>

The problem with your current script is you have your input button call
formHandler with "this". But "this" is really a reference to the input
button, and not the form that you were hoping for. Hope this helps. :)


I've no idea what it all means but it works! Thanks a million, Web.dev.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by James | last post: by
2 posts views Thread by Mark Hannon | last post: by
7 posts views Thread by Steve Wylie | last post: by
5 posts views Thread by Navillus | last post: by
4 posts views Thread by Cerebral Believer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.