Expand my Community achievements bar.

SOLVED

Mutually exclusive check boxes

Avatar

Level 4

I know this question gets asked a lot and I have read through the other posts. My code still isn't working. I've tried every variation I've seen on here, using null instead of 0, using quotation marks, not using quotation marks, double equal signs, no double equal signs...what am I doing wrong? I'm really new to JavaScript so I'm not sure about the syntax stuff yet.

assessment.Questions.Questionset.Questiondetail.TFdetail.False_check::click - (JavaScript, client)

if(this.rawValue=="1")
{
xfa.form.assessment.Questions.Questionset.Questiondetail.TFdetail.True_check.rawValue="null";
}

assessment.Questions.Questionset.Questiondetail.TFdetail.True_check::click - (JavaScript, client)

if(this.rawValue=="1")
{
xfa.form.assessment.Questions.Questionset.Questiondetail.TFdetail.False_check.rawValue="null";
}

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Ok so you are checking the right value. Checkboxes are not mutually exclusive ...radioButtons are. You can change these objects over to RadioButtons and change the appearance of the Radio button to a square to make it look like a checkbox but behave like a radiobutton.

Can you share your form it woudl make it easier to debug.

Paul

View solution in original post

4 Replies

Avatar

Former Community Member

There doesn't seem to be anything wrong with your syntax. I would put an app.alert(this.rawValue) before the if condition to validate that the value you are testing is correct. Then to set something to null you do not put it in quotes. That woudl be the string null and not the value null. Why not set it to '"" an empty string? Lastly when testing the value in the if condition the 1 does not need to be in quotes.

Paul

Avatar

Level 4

Thanks for your help. However, it is still allowing me to check both boxes. I added the app.alert and the value is 1 when I check the box.

Here is the code I have now.

assessment.Questions.Questionset.Questiondetail.TFdetail.True_check::click - (JavaScript, client)
app.alert(this.rawValue)
if(this.rawValue==1)
{
xfa.form.assessment.Questions.Questionset.Questiondetail.TFdetail.False_check.rawValue="";
}

assessment.Questions.Questionset.Questiondetail.TFdetail.False_check::click - (JavaScript, client)
app.alert(this.rawValue)
if(this.rawValue==1)
{
xfa.form.assessment.Questions.Questionset.Questiondetail.TFdetail.True_check.rawValue="";
}

Do I need to put both boxes into their own subform together?

Avatar

Correct answer by
Former Community Member

Ok so you are checking the right value. Checkboxes are not mutually exclusive ...radioButtons are. You can change these objects over to RadioButtons and change the appearance of the Radio button to a square to make it look like a checkbox but behave like a radiobutton.

Can you share your form it woudl make it easier to debug.

Paul

Avatar

Level 4

Thanks Paul!

I wanted to use the checkboxes because I liked the way the data returned better with a checkbox. But I changed them to radio buttons and now it works fine. However, now I am having issues with some of my other buttons. I'm going to post another topic since it's a "new" issue...maybe you can help with that.

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] ----