本文介绍了jsp -two radio buttom和提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单选按钮,在提交时我想要选择一个收音机并点击提交按钮

并转到花药jsp并按下花药无线电转到花药jsp

i have two radio button and on submit i want to when select one radio and click on submit button
and go to anther jsp and when press anther radio go to anther jsp

推荐答案

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
/**
 * Function to load a specific page based on radio button selection.
 */
function radioClickedGet(ctrl) {
   if ("male" === ctrl.value)
      location.replace("YOUR PAGE ONE");
   else if ("female" === ctrl.value)
      location.replace("YOUR PAGE TWO")
}

/**
 * Function to post a form to a specific page based on radio button selection.
 */
function radioClickedPost(ctrl) {
   var strAction;
   if ("male" === ctrl.value)
       strAction = "YOUR PAGE ONE";
   else if ("female" === ctrl.value)
       strAction = "YOUR PAGE TWO";
   var frm = document.getElementById('frmMain');
   frm.action = strAction;
   frm.submit();
}
</script>
</head>
<body>

<form id="frmMain" action="demo.aspx">
  <input type="radio" name="gender" value="male" onclick="radioClickedGet(this);"> Male<br>
  <input type="radio" name="gender" value="female" onclick="radioClickedGet(this);"> Female<br>
  <input type="submit" value="Submit">
</form>
</body>
</html>



问候,


Regards,


这篇关于jsp -two radio buttom和提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:05
查看更多