Expand my Community achievements bar.

Setting Checkbox value

Avatar

Level 1

Hi, very new to Formcalc. I have a simple question: I have two check boxes and if I set one I want to un-set the other. I know Radio buttons do this but I need to use check boxes. My code that is being thrown out is:

 

if (BookingMatrix.Row1.CheckBox[0]==1) then BookingMatrix.Row1.CheckBox[1]=0

I have also tried .value & .rawvalue, neither seem to work. The error I get is "syntax error near token "0"

Can anyone help, please:-)

4 Replies

Avatar

Level 2

Try this.

Using Javascript. Under change, put these for your checkboxs. Rename appropriately.

Checkbox1

if (this.rawValue == "1") {

  this.resolveNode("CheckBox1").rawValue = "0";

}

Checkbox2

if (this.rawValue == "1") {

  this.resolveNode("CheckBox2").rawValue = "0";

}

Avatar

Level 1

Hi, Many thanks for the swift reply, but as I'm using Formcalc throughout the document, I'm not sure how to include Jscript at the same time.

Avatar

Level 2

You should be able to just set those to java and still use formcalc throughout the rest of the form

Avatar

Level 1

Hi,

Code for 1st CB now reads:

if (BookingMatrix.Row1.CheckBox[0].rawValue == "1") {

                BookingMatrix.Row1.CheckBox[1].resolveNode("CheckBox1").rawValue = "0";

}

Code for 2nd CB now reads:

if (BookingMatrix.Row1.CheckBox[1].rawValue == "1") {

                BookingMatrix.Row1.CheckBox[0].resolveNode("CheckBox2").rawValue = "0";

}

No errors, but the CB states do not change when clicked. Was a bit unsure about your "CheckBox1" and "CheckBox2" and whether these need to be replaced with something. Sorry to be a pain....