Expand my Community achievements bar.

Set radio button value using javascript

Avatar

Former Community Member
I am using ALCD 7.1. I have created a yes/no radio button pair and I would like to change the value of the button based on result of message I prompt the user with.



Scenario:



User changes radio button from default value of "Yes" to "No". Upon clicking the "No" option, a message box pops up and asks the user to confirm selection. If user clicks "OK", radio button value should be set to 0. If the user clicks "Cancel", radio button value should be set to 1.



The code seems to work, but the value of the radio button does not change on the form. I suspect the value has been changed, but it isn't rendered on the form.



Any suggestions on how to make this scenario occur based on the user's action? I have been searching the forums for a while now and haven't found anything as of yet.



The code is listed below:



var msgValue = app.alert({

cMsg: "Selecting NO will omit this section's data from being submitted. Proceed?",

nIcon: 1,

nType: 1,

cTitle: "Confirm Action"});



if (msgValue == 0) {

GCVYesNo.rawValue = 1;

}

else {

GCVYesNo.rawValue = 0;

}



Thanks in advance!!!
3 Replies

Avatar

Former Community Member
I have made some progress with this, but I am still unable to make the value on the form change from "No" back to "Yes".



One thing I discovered was that the the buttons msgValue box I pop had different values than I thought. "OK" has a value of 1 and "Cancel" has a value of 2. I discovered this by adding a print statement right before the msgValue variable's evaluation.



Any ideas on how to make the radio button change it's state back using javascript????

Avatar

Former Community Member
I found an alternative solution using check boxes that I plan to use, but if anyone could shed some light on the issue that would be excellent!



Cheers!

Avatar

Level 5
Set the rawValue of the Radio Button field to the value of the choice you want selected.

In my example, Radio_Button3 has 2 values "Yes", and "No".

To set Yes on: Radio_Button3.rawValue = "Yes";

To set No on: Radio_Button3.rawValue = "No";

To reset the button (clear): Radio_Button3.rawValue = "";



Hope this helps.

Mark