我有3页:index.php
,soldc.php
和soldf.php
,如下面的选择选项所示。
在每个页面上,我都有与标题相同的下拉列表。因此,当我单击按钮时,取决于dropown选项,该按钮将重定向到soldc.php或sodf.php,其中显示了不同的信息。我想在下一页上保持下拉菜单选项处于选中状态,我会通过该按钮进行重定向。谢谢。
<html>
<body>
<form name="hop"><br>
<p align="center">
<select name="choose" style="width: 168px;height: 35px;">
<option value="./soldc.php">Sold clienti</option>
<option value="./soldf.php">Sold furnizori</option>
</select>
<input type="button" data-validate="submit" class="btn-primary" onclick="location=document.hop.choose.options[document.hop.choose.selectedIndex].value;" value="Calculate" style="
margin-left: 10px;">
</form>
</body>
</html>
最佳答案
将此放在您的<head>
<script language="JavaScript">
<!--
function MM_jumpMenuGo(objId,targ,restore){ //v9.0
var selObj = null; with (document) {
if (getElementById) selObj = getElementById(objId);
if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0; }
}
</script>
然后使用它作为您的html表单
<form name="form1">
<select name="select" id="select">
<option value="./soldc.php?id=1" <?php if($_GET['id'] == 1) { ?> selected=selected <?php } ?>>Sold clienti</option>
<option value="./soldf.php?id=2" <?php if($_GET['id'] == 2) { ?> selected=selected <?php } ?>>Sold furnizori</option>
</select>
<input type="button" name="go_button" id= "go_button" value="Go" onClick="MM_jumpMenuGo('select','parent',0)">
</form>
希望这可以帮助
关于javascript - 下一页上的保留下拉选项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32410355/