Expand my Community achievements bar.

force rawValue update of a checkbox and dropdown list

Avatar

Former Community Member

Hi All

I have an form filled in with lots of check boxes.

I have assigned an 'On' value for each checkbox as the equivalent component price and kept the 'Off' value as 0.

This is simply so I can perform a calculation at the end of the sheet of all the checkbox rawValues rather than doing creating a complex and long 'if' statement.

The part I am stuck with is I have created a admin area where authorised people can adjust the prices for each component without having to go in to the code.

in the admin area there is a table with a list of components and a numberical field for price and an update button.

Is there a way I can use the update button to change the 'on' value or in the case of a dropdownlist a selection value.

i.e. CheckBox1('on' value) = Table1.Row1.Cell4.rawValue

     DropdownList (selection 2 value) = Table1.Row1.Cell4.rawValue

Just to be clear I am not looking to change what the user views in the dropdown or the status of the checkbox just the hidden rawValue behind it.

hope this is possible as it would save me an enourmous amount of work.

Thanks to all those who can help.

2 Replies

Avatar

Former Community Member

I can address the checkbox issue right now. The drop-down list is little more complicated because you have to manipulate the data bindings.

Imagine I have a checkbox called "form1.page1.subform1.cb1" containing the default bindings where 'On' is 1 and 'Off' is 0. For a text field called "form1.page1.subform1.updateCb1" I can add the following exit event script to update the "On" binding. The "On" binding is the first occurrence of the items node thus the reference to "cb1.items[0]".

// form1.page1.subform1.updateCb1::exit - (JavaScript, client)

xfa.resolveNode("form1.page1.subform1.cb1.items[0].#text").value = this.rawValue;

Steve

Avatar

Former Community Member

Hi All

I managed to do what I needed and thought I might share.

may not be the correct or best way - but it works for me.

Bit of Background

I have three pages in my form from which the results of the first two pages are posted on the last with pricing indication.

I decided to use the rawValue of a checkbox as the price so i can simply do a calculated numerical value on the last page of checkbox1.rawValue + checkbox2.rawValue etc etc

The simple soution I came up with was to use a final button on the last page to process the data and use the following code

if (CheckBox1.rawValue == "1")  then

CheckBox1.rawValue = Admin.Pricetable.Row1.Cell4.rawValue

else

CheckBox1.rawValue = "0"

endif

The above basically means the form will look for the on value and if it is on then will assign a raw value of the price table to the on value when the button is clicked.

You can do the same for a dropdown

if (DropDownList1.rawValue == "2") then

DropDownList1.rawValue = Admin.Pricetable.Row1.Cell4.rawValue

else

DropDownList1.rawValue = "0"

endif

Hope this helps.

Like I said it may not be the correct or best way but it works!