BOS Posted June 13, 2007 Share Posted June 13, 2007 The second question has been solved, and now I have a problem with the enable and disable checkboxes, maybe someone can guide me to the right direction, thanks in advance :-)I have 4 webform checkboxes for 2 questions and I want it to select in one of those checkbox not both for each questions. I try this, but it's not working, can someone give me a better way to enable and disable in one of the checkbox, thankyouif (i==0) {window.document.getElementById("IptChkQues1A").checked = true;window.document.getElementById("ptChkQues1B").checked = false;window.document.getElementById("ptChkQues2A").checked = false;window.document.getElementById("ptChkQues2B").checked = false;}else if (i ==1){window.document.getElementById("IptChkQues1A").checked = false;window.document.getElementById("ptChkQues1B").checked = true;window.document.getElementById("ptChkQues2A").checked = false;window.document.getElementById("ptChkQues2B").checked = false;}else if (i ==2){window.document.getElementById("IptChkQues1A").checked = false;window.document.getElementById("ptChkQues1B").checked = false;window.document.getElementById("ptChkQues2A").checked = true;window.document.getElementById("ptChkQues2B").checked = false;}else if (i ==3){window.document.getElementById("IptChkQues1A").checked = false;window.document.getElementById("ptChkQues1B").checked = false;window.document.getElementById("ptChkQues2A").checked = false;window.document.getElementById("ptChkQues2B").checked = true;}} Link to comment Share on other sites More sharing options...
BOS Posted July 2, 2007 Author Share Posted July 2, 2007 Can someone help me with this, thanks Link to comment Share on other sites More sharing options...
jesh Posted July 2, 2007 Share Posted July 2, 2007 Can someone help me with this, thanksI don't know what you're trying to do (where do the "i"s come from?), but this would be a more efficient (or, at least, easier to read) way to do what you've done:document.getElementById("IptChkQues1A").checked = false;document.getElementById("ptChkQues1B").checked = false;document.getElementById("ptChkQues2A").checked = false;document.getElementById("ptChkQues2B").checked = false;if (i==0){ document.getElementById("IptChkQues1A").checked = true;}else if (i ==1){ document.getElementById("ptChkQues1B").checked = true;}else if (i ==2){ document.getElementById("ptChkQues2A").checked = true;}else if (i ==3){ document.getElementById("ptChkQues2B").checked = true;} Also, I noticed that three of the checkboxes are named "ptChkQues.." but the first one is named "IptChkQues..". Is that by design? Link to comment Share on other sites More sharing options...
BOS Posted July 2, 2007 Author Share Posted July 2, 2007 I don't know what you're trying to do (where do the "i"s come from?), but this would be a more efficient (or, at least, easier to read) way to do what you've done:document.getElementById("IptChkQues1A").checked = false;document.getElementById("ptChkQues1B").checked = false;document.getElementById("ptChkQues2A").checked = false;document.getElementById("ptChkQues2B").checked = false;if (i==0){ document.getElementById("IptChkQues1A").checked = true;}else if (i ==1){ document.getElementById("ptChkQues1B").checked = true;}else if (i ==2){ document.getElementById("ptChkQues2A").checked = true;}else if (i ==3){ document.getElementById("ptChkQues2B").checked = true;} Also, I noticed that three of the checkboxes are named "ptChkQues.." but the first one is named "IptChkQues..". Is that by design? Thanks Jesh for replying, I'm trying to set enable and disable the checkbox, I have 4 checkboxes for 2 questions yes and no, the question 1 can only check either yes or no, not both checked at the same time, and also the same for the question #2, about the "i", it sets it as a variable, so do you have any suggestion of how to implement it, and some code examples, thanks...And the about the checkbox id, it is Id="ptChkQues" not "IptChkQues..". thanks for catching :-) Link to comment Share on other sites More sharing options...
jesh Posted July 2, 2007 Share Posted July 2, 2007 If you are open to changing your design, I might recommend using radiobuttons rather than checkboxes. You can set up radiobutton groups so that only one item in the group can be selected at a time. Check out this page of the HTML tutorial: http://www.w3schools.com/html/html_forms.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.