如何使用jquery和java脚本启用单选按钮上的复选框 [英] how to enable a check box on lick of radio button using jquery and java script

查看:140
本文介绍了如何使用jquery和java脚本启用单选按钮上的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
    <head>
        <title>JSP for StudentForm form</title>
        <script type="text/javascript">
          function getStudent(){
          //alert();
          document.getElementById('stname').value="";
           document.getElementById('stname').disabled=true;//$('stname').attr("disabled","disabled");
           document.getElementById('lbl2').innerHTML=document.getElementById('lbl1').innerHTML;
          }
          function showTextField(){
          document.getElementById('stname').disabled=false;
          }
          function showData(){
           document.getElementById('lbl2').innerHTML=document.getElementById('stname').value;
          }
        </script>
    </head>
    <body>
     <input type="radio" name="s" value="1" onchange="getStudent()"/>NO<label id="lbl1"><c:out value="${StudentForm.studentNo}"></c:out></label>
     <br/>
     <input type="radio" name="s" value="2" onchange="showTextField()"/><input type="text" name="studentName" id="stname" onblur="showData()"/><br/>


        <label id="lbl2">0$</label>
    </body>
</html>

推荐答案

('stname')。attr (禁用,禁用);
document .getElementById(' lbl2')。innerHTML = document .getElementById(' lbl1')。innerHTML;
}
function showTextField(){
document .getElementById( ' stname')。disabled = false ;
}
function showData(){
document .getElementById( ' lbl2')。innerHTML = document .getElementById(' stname')。value;
}
< / 脚本 >
< / head >
< body >
< input type = radio name < span class =code-keyword> = s = 1 onchange = getStudent() / > < label id = lbl1 > < c:out value =
('stname').attr("disabled","disabled"); document.getElementById('lbl2').innerHTML=document.getElementById('lbl1').innerHTML; } function showTextField(){ document.getElementById('stname').disabled=false; } function showData(){ document.getElementById('lbl2').innerHTML=document.getElementById('stname').value; } </script> </head> <body> <input type="radio" name="s" value="1" onchange="getStudent()"/>NO<label id="lbl1"><c:out value="


{StudentForm.studentNo} > < / c:out > < / label >
< br / >
< < span class =code-leadattribute> input type = radio name = s value = 2 onchange = showTextField() / > < input 类型 = text 名称 = studentName id = stname onblur = showData() / > < br / >


< label id = lbl2 > 0
{StudentForm.studentNo}"></c:out></label> <br/> <input type="radio" name="s" value="2" onchange="showTextField()"/><input type="text" name="studentName" id="stname" onblur="showData()"/><br/> <label id="lbl2">0


< / label >
< ; / body >
< / html >


这篇关于如何使用jquery和java脚本启用单选按钮上的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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