我只想在将代码发送到Iframe之后保持选中列表框项目,但我真的不知道该怎么做......这里是我的代码^^
<?PHP
if(isset($_POST['options'])){
$epinum = $_POST['options'];
}
?>
<form action="" method="post">
<SELECT class='listofepisodes' NAME='options' onchange='this.form.submit()' size='1200'>
<?PHP
$options=mysql_query("SELECT * FROM table");
while($option=mysql_fetch_array($options)) {
$image=$option['link'];
$number=$option['number'];
?>
<option value="<?PHP echo $image; ?>">Option <?PHP echo $number; ?></option>
<?PHP } ?>
</SELECT>
</form>
<iframe name="iframe" src="<?PHP echo $epinum; ?>" height="388" width="640" frameborder="1" allowfullscreen></iframe>
答案 0 :(得分:1)
只需将$ _POST [&#39;选项&#39;]与$ image和echo&#39;选择&#39;进行比较选项标签如下:
<?PHP
if(isset($_POST['options'])){
$epinum = $_POST['options'];
}
?>
<form action="" method="post">
<SELECT class='listofepisodes' NAME='options' onchange='this.form.submit()' size='1200'>
<?PHP
$options=mysql_query("SELECT * FROM table");
while($option=mysql_fetch_array($options)) {
$image=$option['link'];
$number=$option['number'];
?>
<option value="<?PHP echo $image; ?>" <?php if(isset($_POST['options']) && $_POST['options']==$image) echo 'selected'; ?>>Option <?PHP echo $number; ?></option>
<?PHP } ?>
</SELECT>
</form>
<iframe name="iframe" src="<?PHP echo $epinum; ?>" height="388" width="640" frameborder="1" allowfullscreen></iframe>