<?php
/*自己的選項*/
$url[] = array('url' => 'http://tw.yahoo.com','option' => 'yahoo.tw');
$url[] = array('url' => 'http://cn.yahoo.com','option' => 'yahoo.cn');
?>
<html>
<head>
<script>
function chglink() {document.getElementById("link").innerHTML = document.getElementById("addr").value;}
function chgFrame() {document.getElementById("iframe1").src = document.getElementById("link").innerHTML;}
</script>
</head>
<body>
自己的選項
<?php print_r($url);?>
<hr>
<table border="1">
<tr><td>有select表單</td></tr>
<tr><td>php在table內<select id="addr" onchange="chglink();">
<?php
foreach($url as $k => $v)
echo '<option value="'.$v["url"].'">'.$v["option"].'</option>';
?>
</select></td></tr>
<tr><td>會顯示url(<a id="link" href="#" onclick="chgFrame();"></a>),請點我控制iframe</td></tr>
<tr><td><iframe id="iframe1" src="<?php echo $url[0]["url"];?>" width="600px" height="400px"></td></tr>
</table>
</body>
</html>
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- <html>
<head>
<script>
function chglink() {document.getElementById("link").innerHTML = document.getElementById("addr").value;}
function chgFrame() {document.getElementById("iframe1").src = document.getElementById("link").innerHTML;}
</script>
</head>
<body>
自己的選項
Array
(
[0] => Array
(
[url] => http://tw.yahoo.com
[option] => yahoo.tw
)
[1] => Array
(
[url] => http://cn.yahoo.com
[option] => yahoo.cn
)
)
<hr>
<table border="1">
<tr><td>有select表單</td></tr>
<tr><td>php在table內<select id="addr" onchange="chglink();">
<option value="http://tw.yahoo.com">yahoo.tw</option><option value="http://cn.yahoo.com">yahoo.cn</option></select></td></tr>
<tr><td>會顯示url(<a id="link" href="#" onclick="chgFrame();"></a>),請點我控制iframe</td></tr>
<tr><td><iframe id="iframe1" src="http://tw.yahoo.com" width="600px" height="400px"></td></tr>
</table>
</body>
</html>
preferences:
85.05 ms | 413 KiB | 5 Q