我在做一个简单页面,要实现一个下拉菜单选择一个值,然后点击图片,就转到相应的网址。
<FORM method=post name=form1 action=#>
<SELECT name=selectProperty1 style="width:200px;color:#808080;">
<option value="1">网址1</option>
<option value="2">网址2(</option>
<option value="3">网址3</option>
<option value="4">网址4</option>
</select>
</form>
<a href="index.html"><img src="images/joatop7.gif" alt="马上订购" /></a>
类似这样,我想问下有没有什么好的方法实现?
<FORM method=post name=form1 action=#>
<SELECT name=selectProperty1 style="width:200px;color:#808080;">
<option value="1">网址1</option>
<option value="2">网址2(</option>
<option value="3">网址3</option>
<option value="4">网址4</option>
</select>
</form>
<a href="index.html"><img src="images/joatop7.gif" alt="马上订购" /></a>
类似这样,我想问下有没有什么好的方法实现?
<!-- saved from url=(0054)http://www.755shop.cn/demo/2003/b2b_cpinfo.asp -->
<HTML><HEAD><TITLE>test</TITLE></HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<script>
onchanges(){
var src=form1.selectProperty1;
document.getElementById('aa').href=src.value;
}
</script>
<body>
<table>
<tr>
<td>
<FORM method=post name=form1 action=#>
<SELECT name=selectProperty1 style="width:200px;color:#808080;" onchange="return onchanges();">
<option value=" www.baidu.com">网址1 </option>
<option value=" www.g.cn">网址2 </option>
<option value=" www.163.com">网址3 </option>
<option value=" www.sina.com">网址4 </option>
</select>
</form> <a id='aa' href="test.html"> <img src="images/joatop7.gif" alt="马上订购" /> </a>
</td>
</tr>
</table>
</body>
</HTML>我这样为什么实现不了呢?
<option value=" www.baidu.com">网址1 </option>
<option value=" www.g.cn">网址2 </option>
<option value=" www.163.com">网址3 </option>
<option value=" www.sina.com">网址4 </option>
</select>
一定可以的
{
var src=form1.selectProperty1;
document.getElementById('aa').href=src.options[src.options.selectedIndex].value;
}