繁体   English   中英

每个单选按钮都会通过“ onclick”而不是“ submit”自动重定向到不同选择的不同页面

[英]Each radio button automatically redirect to the different pages on different selections through 'onclick' and not from 'submit'

我想根据用户的不同选择来重定向不同的页面,我的代码仅适用于一页,而当我选择另一页时,它会挂起并仅显示第一页的内容。 我必须每次在浏览器中按返回选项才能查看2、3或4页的内容,否则卡住了。 该代码是

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script type="text/javascript">
function idForm(){
var selectvalue = $('input[name=choice]:checked', '#idForm').val();
if(selectvalue == "all"){
window.open('index.php','_self');
return true;
}
else if(selectvalue == "pc"){
window.open('pc.php','_self');
return true;
}
else if(selectvalue == "ps2"){
window.open('ps2.php','_self');
return true;
}else if(selectvalue == 'ps3'){
window.open('ps3.php','_self');
return true;
}else if(selectvalue == 'psp'){
window.open('psp.php','_self');
return true;
}
return false;
};
</script>
</head>
<body>
Games - This is the full List of Games, if you want to choose the games according to the Platform then select it <br /><br />
<form id="idForm">
<input type="radio" onClick="idForm()"  name="choice" value="all" checked/>All &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" onClick="idForm()"  name="choice" value="pc"/>PC &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio"  onclick="idForm()" name="choice" value="ps2"/>PS2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio"  onclick="idForm()" name="choice" value="ps3"/>PS3 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio"  onclick="idForm()" name="choice" value="psp"/>PSP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</body>
</html>

再次在浏览器中再次按返回选项可帮助我解决此问题,并分别查看每个页面的内容,或者正常选择单选按钮all,pc,ps2,ps3或psp,而无需挂起。

提前致谢。

为什么不简化

<form id="idForm">
<input type="radio" onClick="window.open('index.php','_self')"  name="choice" value="all" checked/>All 
<input type="radio" onClick="window.open('pc.php','_self')"  name="choice" value="pc"/>PC 
<input type="radio" onclick="window.open('ps2.php','_self')" name="choice" value="ps2"/>PS2 
<input type="radio" onclick="window.open('ps3.php','_self')" name="choice" value="ps3"/>PS3 
<input type="radio" onclick="window.open('psp.php','_self')" name="choice" value="psp"/>PSP 
</form>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM