通过select里面的option修改Iframe内容

来源:互联网 发布:三国群英传7 mac 编辑:程序博客网 时间:2024/05/15 23:43

今天完成了一个貌似很难的程序,比较欣慰,写出来,省的忘了

想通过选择select里面的option,然后根据选择的内容,完成对iframe里面内容的改变

<select name="select_color" onclick="document.getElementById('myframe').src=this.options[this.selectedIndex].value;">

这里完成的工作是改变myframe的src值,这样,就可以改变对它传递的参数

<option value="other.php?test=5;">ttt</option>

<option value="other.php?test=6;">ppp</option>

<iframe src="other.php" name="myframe" id="myframe"></iframe>

这样就完成了整个操作

即,选择ttt时,iframe的对应网页得到的是test=5的值

 

另外需要设个默认的,即<option>选择</option>

这样防止鼠标点击发生不该发生选择

原创粉丝点击