...

View Full Version : Opening a Select Menu Link in a New Window



bspahr
01-24-2005, 10:41 PM
I have the following html select menu - I want to be able to open some of the links in there own windows. I tried to use target="_blank" but could not get it to work.


<form>
<td>
<select id="UserGroups" name="shortcut" onChange="if (this.form.shortcut[this.form.shortcut.selectedIndex].value) window.location=this.form.shortcut[this.form.shortcut.selectedIndex].value;" style="font: 10px verdana, arial, sans-serif; color: #636163; text-decoration: none;">
<option value="">Navigation >></option>
<option value="1.asp">Link 1</option>
<option value="2.asp">Link 2</option>
<option value="3.asp">Link 3</option>
<option value="4.asp">Link 4</option>
</select>
</td>
</form>

Brandoe85
01-25-2005, 01:50 AM
You could use window.open();

glenngv
01-25-2005, 04:12 AM
<form>
<td>
<select id="UserGroups" name="shortcut" onChange="doOpen(this)" style="font: 10px verdana, arial, sans-serif; color: #636163; text-decoration: none;">
<option value="">Navigation >></option>
<option value="_blank|1.asp">Link 1</option>
<option value="_self|2.asp">Link 2</option>
<option value="_self|3.asp">Link 3</option>
<option value="_self|4.asp">Link 4</option>
</select>
</td>
</form>
<script type="text/javascript">
function doOpen(oSel){
var strValue = oSel.options[oSel.selectedIndex].value;
if (strValue){
var arr = strValue.split("|");
var w = window.open(arr[1], arr[0]);
w.focus();
}
}
</script>

bspahr
01-25-2005, 04:01 PM
glenngv -

Worked perfectly, thanks for your help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum