我有3个页面:index.php
,soldc.php
和soldf.php
,如下面的选择选项。
在每个页面上,我都有与标题相同的下拉列表。因此,当我单击按钮时,根据下拉选项,按钮重定向到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>
答案 0 :(得分:1)
将其放在<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>
<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>
然后将其用作html表单
{{1}}
希望这有帮助
答案 1 :(得分:0)
我不确定这会有效,但我认为它会:
$(document).ready(function() {
$("#selection").change(function() {
location = $("#selection option:selected").val();
});
});
HTML
<p align="center">
<form name="hop" class="center">
<select name="choose" id="selection" style="width: 168px;height: 35px;">
<option value="#">Select an option</option>
<option value="/link1.shtml">Link 1</option>
<option value="/link2.shtml">Link 2</option>
<option value="/link3.shtml">Link 3</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>
</p>
答案 2 :(得分:0)
当您转到目标页面时,意味着您最后选择的选项是当前页面,我是否正确?在每个页面中使用以下js代码:
var option = document.location.pathname.match(/[^\/]+$/)[0];
document.getElementById('select').value = option;
更改此行<select name="choose" style="width: 168px;height: 35px;">
到这个
<select id=select name="choose" style="width: 168px;height: 35px;">