Forum Moderators: open

Message Too Old, No Replies

please help with this html i,m trying to create a dropdown menu

         

midi25

2:33 pm on Jul 2, 2002 (gmt 0)

10+ Year Member



Hi im workind in DW/Ultra dev. i have submitted a form on my page and put in a drop down box. I wnat to put in my page names so people can just select from the drop down click and go.

the problem i am having is that it works fine but when i go to click on something it dosnt go anywhere i.e it hast linked.

Here is the html for my dropdown. please can you see how i can get this to work thanks

<form name="MyForm" method="get" action="what do i put in here please??">
<select name="select">
<option value="http://www.myurl.com">Home</option>
</select>
</form>

korkus2000

2:36 pm on Jul 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You put the path to the script/page/function that will process the form in the action attribute. If it is javascript then it would be yourFunctionsName(). If it is a script or cgi program it would be cgi-bin/scriptname.pl. If it is an ASP or PHP process page then it is processpage.asp.

You don't have a submit button. You will either need a submit button or an onChange event handler so it will fire.

korkus2000

3:03 pm on Jul 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is an easy javascript drop down:

<script language="JavaScript" type="text/javascript">
<!--
function getIt(){
location=document.myform.drop.options[document.myform.drop.selectedIndex].value;
}
//-->
</script>
<form name="myform">
<select name="drop" onChange="getIt()">
<option value="http://www.myurl.com">Home</option>
</select>
</form>

gsx

4:05 pm on Jul 2, 2002 (gmt 0)

10+ Year Member


Some would/could modify that to include a 'go' button:

<script language="JavaScript" type="text/javascript">
<!--
function getIt(){
location=document.myform.drop.options[document.myform.drop.selectedIndex].value;
}
//-->
</script>
<form name="myform" action="getIt()">
<select name="drop" onChange="getIt()">
<option value="http://www.myurl.com">Home</option>
</select>
<input type="submit" value="Go">
</form>

It's personal preference and support for any browsers that may not support onChange. I can't think of any, but there may be some older ones out there.

midi25

4:50 pm on Jul 2, 2002 (gmt 0)

10+ Year Member



i dont want a submit dropdown. i have the type of one i want on this page. but i cannot get it to work. could someone help me or tell me how i can make one like this in DW/Ultradev

[edited by: midi25 at 5:22 pm (utc) on July 2, 2002]

korkus2000

4:51 pm on Jul 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My code above achieves this. Copy and paste it where you want the dropdown to go. Add options as needed.

Knowles

4:54 pm on Jul 2, 2002 (gmt 0)

10+ Year Member



midi this is what they have created for you.

<script language="JavaScript" type="text/javascript">
<!--
function getIt(){
location=document.myform.drop.options[document.myform.drop.selectedIndex].value;
}
//-->
</script>
<form name="myform" action="getIt()">
<select name="drop" onChange="getIt()">
<option value="http://www.myurl.com">Home</option>
<option value="http://www.myurl.com/page">page</option>
<option value="http://www.myurl.com/page1">page1</option>
<option value="http://www.myurl.com/page2">page2</option>
<option value="http://www.myurl.com/page3">page3</option>
</select>
<input type="submit" value="Go">
</form>

Just add in a a new option each time.

ps you might want to take the URL out of your last post before a mod spots it and removes for you. They dont like for people to drop URLs just add it to your profile.

midi25

5:23 pm on Jul 2, 2002 (gmt 0)

10+ Year Member



ok thats fine thanks. but what do i put in as my action?

korkus2000

5:27 pm on Jul 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It all works just throw the code in and change the <option> tags to where you really want them to say and go.

Knowles

5:31 pm on Jul 2, 2002 (gmt 0)

10+ Year Member



In Korkus's example you dont need the action. The javascript does all the action. In gsx's example you put the javascript call in the action. This allows the go button to work. Otherwise you dont need it.