Javascript to display text if a radio button is checked
I have a form that has 4 groups of radio buttons with the values Yes and No. This is how I have it set up:
The first radio button group is titled AS. Each option has the title AS under the General Tab and under the Option tab the "Radio Button Choice" is either Yes or No.
What I want to do is display a simple message formated with red text to the user if they select Yes in this group
My thought was to have a text field with the tool tip containing has my message and then to use the following code:
var ASValue = this.getField("AS").valueAsString;
if (ASValue == "Yes"){
event.value = Message.userName; //Message is the name of the text field that I want to put the default message in, userName is the tooltip in that same field.
} else {
event.value = "";
}The way I look at it, this code should display the tooltip as the default value of the message text field if they select the Yes radio button. If they select No, the message would disappear. It doesn't work at all. I have tried to add this to the Validate and the Calculate tabs for the Message text field and nothing happens.
Once I get that to work I will add OR statements for the other fields in a more complicated code like this:
var ASValue = this.getField("AS").valueAsString;
var GorBValue = this.getField("GorB").valueAsString;
var OSDValue = this.getField("OSD").valueAsString;
var DMValue = this.getField("DM").valueAsString;
if (ASValue == "Yes" || GorBValue == "No" || OSDValue == "Yes" || DMValue == "No"){
event.value = Message.userName;
} else {
event.value = "";
}The above code would display the tooltip of the Message field if any of the radio buttons are selected Yes or No depending on the question.
Any tips on what I am doing wrong would help. If there is a better way to display a message instead of in a text field let me know. I couldn't find a way to conditionally display a message from just a text box.
