1

我有基本的工作,我只需要正确的 src 从下拉列表中获取链接。到目前为止的代码:

<form name="dropdownMenu" method="post">
<select name="Select1" style="width: 128px">
    <option value="pages/page1.php">Page1</option>
    <option value="pages/page2.php">Page2</option>
</select>
<input name="Button1" type="button" value="GO"
onclick='document.getElementById("content").
src="THIS IS WHAT I CANT MAKE WORK";'>

如果我将 src 更改为“pages/page1.php”,它会很好地加载 iframe,只是似乎无法让它从下拉列表中加载值。

4

2 回答 2

0

给您的 SELECT 一个 id,然后引用 SELECT 的值

<form name="dropdownMenu" method="post">
<select id="Select1" name="Select1" style="width: 128px">
    <option value="pages/page1.php">Page1</option>
    <option value="pages/page2.php">Page2</option>
</select>
<input name="Button1" type="button" value="GO"
onclick='document.getElementById("content").
src=document.getElementById("Select1").value;'>
于 2012-10-20T15:37:12.573 回答
0
    <script type="text/javascript">
 function newSrc() {
  var e = document.getElementById("MySelectMenu");
  var newSrc = e.options[e.selectedIndex].value;
  document.getElementById("MyFrame").src=newSrc;
 }
</script>

<select id="MySelectMenu">
<option value="http://www.example.com">Website</option>
</select>

<button onClick="newSrc();">Load new source</button>
于 2014-11-28T11:38:17.707 回答