jsp -two radio buttom和提交按钮 [英] jsp -two radio buttom and on submit button

查看:43
本文介绍了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

推荐答案

您好,



您可以为单选按钮编写onclick处理程序,并发布表单或发送GET请求到所需的页面。请参阅下面的代码段。

Hello,

You can write a onclick handler for your radio buttons and either POST a form or send a GET request to required page. See the code snippet below.
<!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和提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆