javascript - how to disable multiple checkboxes when i select radio button? -
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ page iselignored="false" %> <%@ page import="java.util.*"%> <%@page import="com.ba.retrievedetails"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <script type="text/javascript"> history.forward(); function validate(logfile){ var count=0; (var i=0; i<logfile.length; i++) { if (logfile[i].checked) { count++; } } if (count < 1) { alert("please select log fille(s)"); homecoming false; } } </script> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>log files</title> </head> <body> <form name="logfiles" action="retrievelogfiles" method="get" onsubmit=""> <% hashmap hs=new hashmap(); hs=(hashmap)session.getattribute("key"); session.getattribute("key"); string hosts[]=(string[])session.getattribute("hosts"); %> <br> <br> <img src="ba_logo1.bmp" align="right" alt="british airways"> <table> <tr> <% if(hs.size()== 0) {%> <td><h3>authentication fail or not have access unixbox.click <a href="login.jsp">here</a> login</h3></td> <% } else { for(int i=0;i<hosts.length;i++) { %> <h3><p><%out.println(hosts[i]+"\n");%></p></h3> <% arraylist al=new arraylist(); al=(arraylist)hs.get(hosts[i]); int flag=al.size(); %> <td> <table border="2" cellpadding="4"> <% if(flag==0) {%> <td> <h3><p style="color:#ff0000">no log files display</p></h3> </td> <% }else{ for(int j=0;j<al.size();j++) { string lines[]=al.get(j).tostring().split("\\r?\\n"); for(int len=0;len<lines.length;len++) { %> <tr> <td><%out.println(lines[len]);%></td> <td><input type="checkbox" name="logfile" id="logfile" value="<%=hosts[i]+"$"+lines[len]%>"></td> <td><input type="radio" name="logfileview" id="logfileview" value="<%=hosts[i]+"$"+lines[len]%>"></td> </tr> <% }%> </table> </td> </tr> </table> <% } } }%> <input type="submit" name="get logs" align="middle" value="get logs" onclick="return validate(logfile)" > <% } %> </form> </body> </html>
here when press radio button in logfileview.it has disable check boxes logfile? vice versa needed. please help on
logfileview radio button , logfile checkbox.here multiple checkboxes , multiple radiobuttons iam using.
you can accomplish using these javascript code first, loops elements(ex: check boxes), add together onclick event listener them. within looping disable radio buttons when click on check boxes, same logics applied radio buttons:
var logfiles = document.getelementsbyname("logfile"); var logfileviews = document.getelementsbyname("logfileview"); //to disable radio buttons when click on check box (var i=0, count=logfiles.length; < count; i++) { logfiles[i].onclick = function() { (var j=0, count=logfileviews.length; j < count; j++) { logfileviews[j].disabled = true; } }; } //to disable check boxes when click on radio button (var i=0, count=logfileviews.length; < count; i++) { logfileviews[i].onclick = function() { logfiles.disabled = true; (var j=0, count=logfiles.length; j < count; j++) { logfiles[j].disabled = true; } }; } javascript
No comments:
Post a Comment