Click to See Complete Forum and Search --> : select option open new window


jo_clay_
12-20-2002, 08:02 AM
Hi!

Can anyone help me? I'm relatively new with javascript but would like to increase the usability of a site I'm designing by doing the following:

When user selects an option from a drop down selection list, they open a new window, relevant to the option they have just selected.

I think I need the onselect function or something similar.

It's just for a prototype, for visual effect. For the final site I'll be using PHP to pass variables around. Was thinking PHP is the only way I could do this task anyway but if any one knows how to to this that would be great :)

Jo

pyro
12-20-2002, 09:31 AM
This should be the code you need.


<!--This code goes in the HEAD-->

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function pulldown(form) {

var name = "popup";
var windowproperties = "width=550,height=300,location=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,left=150,top= 150";
var URL = form.menu.options[form.menu.selectedIndex].value;

window.open(URL,name,windowproperties);
}
// End Hide -->
</script>

<!--This code goes in the BODY-->

<form name=form>
<select name=menu SIZE=1 onChange="pulldown(this.form)">
<option value="#">Go to....
<option value="http://www.yahoo.com">Yahoo
</select>
</form>


Note: the var windowproperties all goes on one line. The forums just split the lines...