簡體   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