Jump to content

2 questions: Checkbox save to DB and select information


BOS

Recommended Posts

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

  • 3 weeks later...
Can someone help me with this, thanks
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?

Link to comment
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...