我想要一个下拉菜单和
如何更改以下代码以使其按上述方式工作?
<form name="blah_blah">
<select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;">
<option value="first_option_name" selected>option display name</option>
<option value="external link 1">1st link name</option>
<option value="external link 2">2nd link name</option>
</select>
<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab')">
</form>
谢谢!
答案 0 :(得分:2)
检查此代码
<html>
<body>
<form name="blah_blah">
<select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;">
<option value="" selected>Select Site</option>
<option value="http://www.yahoo.com">Yahoo!!!</option>
<option value="http://www.gmail.com">Gmail</option>
<option value="http://www.google.co.in">Google</option>
<option value="http://www.facebook.com">Facebook</option>
</select>
<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab'+ddmenu_name.value)">
</form>
</body>
</html>
希望这是你需要的......
答案 1 :(得分:1)
试试这个:
HTML:
<form name="blah_blah">
<select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;">
<option value="first_option_name" selected>option display name</option>
<option value="external link 1">1st link name</option>
<option value="external link 2">2nd link name</option>
</select>
<input type="button" name="Submit" id="Submit" value="Go!">
</form>
jQuery:
$(document).ready(function(){
var Link = $('#ddmenu_name').val();
$('#Submit').click(function() {
window.open(Link,'_blank');
});
});