Need javascript ?
I know almost nothing about javascript - can someone help !
I am setting up a very simple form which will have just one menu or list with about 6 or 8 items in it. Rather than collecting information to send to an email address as most forms do I want each item to take the user to a different URL. I could just put standard html links on the page I really want the list/menu. From the researchI have done I gather that I can use javascript for this rather than more complex cgi script etc.
Where can I get such a javascript ? Does anyone know one ?
Thankyou in advance.
Blue
Busy posted this at 01:19 — 29th August 2001.
He has: 6,151 posts
Joined: May 2001
something like this? (Its not a javascript as such)
Opera
Windows
Netscape
Blue posted this at 10:27 — 29th August 2001.
They have: 112 posts
Joined: Aug 2001
Thanks that's excellent. It works really well. What kind of script is that - is it html ?
What would I change in the script so that users click a submit button to activate the form rather than it activating automatically ? (just to maintain consistency with other parts of the site)
Blue
Metatrox posted this at 21:11 — 5th September 2001.
They have: 20 posts
Joined: Sep 2001
Yes its HTML its just a Form Select Box.
Suzanne posted this at 02:26 — 6th September 2001.
She has: 5,507 posts
Joined: Feb 2000
It is JavaScript -- just embedded JavaScript.
it is NOT straight HTML.
To use a button, you would take the onChange="" information and put it into onSubmit="" in the element, and add a regular submit button to the form.
Suzanne
Blue posted this at 02:50 — 6th September 2001.
They have: 112 posts
Joined: Aug 2001
Thnaks Suzanne I just tried it but when I click submit it thinks for a minute but stays on the same page. Something I've done ain't right. Do I need to change the following values for the submit button ?
Do I delete the onChange tag when I create the onSubmit tag ?
Thanks, Blue
Suzanne posted this at 04:07 — 6th September 2001.
She has: 5,507 posts
Joined: Feb 2000
Opera
Windows
Netscape
You should really check out tutorials on JavaScript and forms. It would be worth your while. irt.org is a good place to start, but it will require some concentration on your part.
Suzanne
Blue posted this at 01:25 — 8th September 2001.
They have: 112 posts
Joined: Aug 2001
You are quite right Suzanne I do need to learn about it. I looked at irt.org - looks quite complicated. But I'll give it a go.
I copied and pasted the code in your last post and it still doesn't work so beats the heck out of me. I tried another similar script and still the same problem. Maybe it's my browser or something. As far as I know java is enabled on it. It seems to start the search but returns to the same page.
Oh well, thanks for your help anyway.
Cheers, Blue
Keegan posted this at 01:47 — 8th September 2001.
They have: 300 posts
Joined: Aug 2001
<?php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<script language=\"JavaScript\">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<form name=\"form1\" method=\"post\" action=\"\">
<p><font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#006600\">Through
This Web Site</font> </p>
<blockquote>
<p>
<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\">
<option selected>Select</option>
<option value=\"sales.shtml\">Sales</option>
<option value=\"billing.shtml\">Billing</option>
<option value=\"kevin_kilcline.shtml\">Kevin</option>
<option value=\"christina_kilcline.shtml\">Christina</option>
</select>
</p>
</blockquote>
</form>
/body>
/html>
?>
{edit}The board keeps hacking off the last body and html tag. {edit}
You are probally missing the head tags to make the javascript itself work.
Test that in a new page.
K
MBSHost.com
SigHost Project
Suzanne posted this at 02:19 — 8th September 2001.
She has: 5,507 posts
Joined: Feb 2000
For what it's worth -- if you post a url, it's easier for people to troubleshoot for you. We can't tell if you're doing something wonky or not that would conflict or cause problems (like line breaks) without that.
Suzanne
Blue posted this at 02:54 — 8th September 2001.
They have: 112 posts
Joined: Aug 2001
Keegan, you could be right about the missing tags but then why does the code posted by Busy work ok ?
The script you have just posted now worked fine but still the problem of no submit button.
Suzanne, you are right again of course and I would have posted the url straight up by i'm not ready to put it 'out there' yet. Very soon though.
Blue
Keegan posted this at 02:57 — 8th September 2001.
They have: 300 posts
Joined: Aug 2001
Didnt realize you wanted a submit button.
Here ya go
<?php
<form name=\"form1\" method=\"post\" action=\"\">
<p><font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#006600\">Through
This Web Site</font> </p>
<blockquote>
<p>
<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\">
<option selected>Select</option>
<option value=\"sales.shtml\">Sales</option>
<option value=\"billing.shtml\">Billing</option>
<option value=\"kevin_kilcline.shtml\">Kevin</option>
<option value=\"christina_kilcline.shtml\">Christina</option>
</select>
<input type=\"submit\" name=\"Submit\" value=\"go\">
</p>
</blockquote>
</form>
?>
K
MBSHost.com
SigHost Project
Busy posted this at 01:05 — 9th September 2001.
He has: 6,151 posts
Joined: May 2001
Sorry Blue, after I posted the first part I lost the message. didnt realise you needed the extra part.
Looks like the others have sorted it
Suzanne is right, forms look hard but once you get it, your set, a little like tables.
forms are HTML, you dont need to know any JavaScript, but once you know forms you may wish to include it within them - there are so many options
good luck
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.