Expand my Community achievements bar.

SOLVED

How to Deselect 1 Checkbox When Selecting Another

Avatar

Level 2

So please read before answering.

I have two checkboxes in a section of my form.  A question is asked and if the answer is yes, and they click the appropriate checkbox, I make one subform visible so they can input the appropriate answer for Yes. in that statement, I want to make sure the Checkbox for No becomes unchecked and the associated subform for no is hidden.  Making the subform hidden is no problem but I can't figure out how to make the checkbox for No become unchecked.

And vice versa for the no checkbox.  Is there a way to change the value?  I have tried using ".checked = 0" in my if statement for the no Checkbox when yes is selected and ".defaultChecked = 0" and neither is recognized.

I know everyone says:  "Use radio buttons."  Well I neither like the look of those in the form, even making them square, nor how they appear in the form's heirarchy.  It makes things to messy.

So any help out there? 

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Check this link out.  It gives a way of making a group of check boxes behave like radio buttons.

http://blogs.adobe.com/formfeed/2008/10/build_a_better_exclusion_group.html

View solution in original post

4 Replies

Avatar

Correct answer by
Former Community Member

Check this link out.  It gives a way of making a group of check boxes behave like radio buttons.

http://blogs.adobe.com/formfeed/2008/10/build_a_better_exclusion_group.html

Avatar

Level 2

Thank you AJP!

That was perfect.  I feel like I must have been in a daze this morning when I was trying to set the deselected/unchecked box to everything but "null."

Much appreciated.

Avatar

Level 10

I don't really understand this...you can make them exactly the same as checkboxes.

You're worrying about things that don't matter in the greater scheme...Just trying to be helpful here, I generally don't like making more work for myself if I don't have to.

But, if you really want to make more work for yourself:

You have to set the rawValue of the checkbox to its on or off state (usually 1/0 unless it's been changed).

This would go on the first checkbox (along with your show/hide logic):

if (this.rawValue==1) {

checkbox2.rawValue=0;

}

And then you'd want the opposite on the other checkbox.

Avatar

Level 2

Thanks for the input Jono.  I understand your reasoning but when I was trying to make the change from checkbox to radio buttons when the problem first arose, nothing seemed to be working.  All my scripts failed to execute and even using 0 didn't seem to help.  Maybe a spelling error when I changed the code, don't know.   Hence the question on making checkboxes mutually exclusive.  I know the look of the heirarchy matters less that how the form actually works, but I just like the look.

As I mentioned before, I had to go with setting the rawValue=null for the proper result, based upon a comment from the prior poster.  I guess I need to brush up on my JavaScript some more.  And it is always fun to learn something new instead of going with what everyone else uses!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----