我有5个下拉列表依赖于彼此,并且它们填充了来自sql数据库的5个表中的数据。最后一个下拉列表中包含来自具有超链接的列的数据,例如:http://social.msdn.microsoft.com
我应该在第5个下拉菜单中添加哪些信息才能转到该链接网站?它将此时的列解释为文本。下拉列表是简单的样式版本:
<select>
<option></option>
</select>
答案 0 :(得分:0)
给select
一些id,f.e:
<select id="selectbox_with_url">
<option></option> // here will be your items
</select>
然后使用它:
<script type="text/javascript">
var urlmenu = document.getElementById('selectbox_with_url');
urlmenu.onchange = function() {
// if you want to open it on new tab (or popup) - depends on browser settings:
window.open(this.options[ this.selectedIndex ].value, '_blank');
// or if you want to follow that location from option's selected item:
window.location = this.options[ this.selectedIndex ].value;
};
</script>
<强> window.open(URL,名称,规格,取代): 名称:
_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window (Note: the name does not specify the title of the new window)