PDA

View Full Version : dropdown menu



mkalishoek
Dec 3rd, 2002, 12:53 PM
hi!
i am making a website wich must contains a dropdown menu.
im using this:
but now it want to remove the GO! button.
I tried to delete the last part 9<input type="button" name="test" value="Go!"
onClick="gone()">) but when i did that, my site loaded much slower :eek:
how can i remove that GO! button without making it slower?
and how can i make it, that the link you selected in the menu, opens in a new window?

<form name="jumpy">
<p><select name="example" size="1" onChange="gone()">
<option value="http://www.cnet.com">Cnet</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.geocities.com">Geocities</option>
</select>

<script language="javascript">
<!--



function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}
//-->
</script>

<input type="button" name="test" value="Go!"
onClick="gone()">
</p>
</form>


greetings, michiel

tommysphone
Dec 3rd, 2002, 01:19 PM
<form NAME="jumpy">
<p><font face="Tahoma"><select size="1" class="text121" name="URL"
onChange="if(options[selectedIndex].value)

window.location.href=

(options[selectedIndex].value)">
<option Value="#" SELECTED>Select</option>
<option Value="http://www.cnet.com">Cnet</option>
<option Value="http://www.cnn.com">CNN</option>
<option Value="http://www.geocities.com">Geocities </option>
</select></font></p>
</form>

That'll do it in the same window.

mkalishoek
Dec 3rd, 2002, 01:22 PM
Woohoo! It works!
tnx mate! :D :D

glenngv
Dec 4th, 2002, 03:01 AM
function openURL(objSelect){
if (objSelect.selectedIndex!=0)
win = window.open(objSelect.options[objSelect.selectedIndex].value,"_blank");
win.focus();
}

then call it like this:

<select size="1" class="text121" name="URL"
onChange="openURL(this)">
<option value="#" SELECTED>Select</option>
<option value="http://www.cnet.com">Cnet</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.geocities.com">Geocities</option>
</select>

That will always open the selected site in a new window even if that site is already opened.
If you want a site that is already opened and again selected in the list and will open in that same new window,
you need to change this line:

win = window.open(objSelect.options[objSelect.selectedIndex].value,"_blank");

to:

win = window.open(objSelect.options[objSelect.selectedIndex].value,objSelect.options[objSelect.selectedIndex].text);

As you notice, I set the window target to be the text property of the selected item.
So make sure that will have no special characters like .,'@`~- etc... because they are not allowed in the target