Expand my Community achievements bar.

Radio button showing and hiding a text field

Avatar

Level 2

I have a set of 8 radio buttons. The eighth button, if selected, displays a hidden text field. The javaScript on the eighth button, on the mouseUp event, for this is: 

if(this.rawValue)

     AR05.sfBody.sfRows.txtOther.presence = "visible";

else

     AR05.sfBody.sfRows.txtOther.presence = "hidden";

My problem is that on clicking the eighth the text field becomes visible. However, if I click on another radio button the text field is not hidden.

Can anybody help me please.l

5 Replies

Avatar

Level 7

you need to put your code in the click event of the radiobutton list (rather than the individual button) and then just put something like:

if (this.rawValue == 8) {

   AR05.sfBody.sfRows.txtOther.presence = "visible";

    }

else {

AR05.sfBody.sfRows.txtOther.presence = "hidden";

}

Avatar

Former Community Member

Also, when I use Javascript to hide a field, instead of "hidden" I've sucessfully been using "invisible" instead.  For example:

Button3.presence = "invisible";

I don't know much about it it though, "hidden" might work too.

I agree with whyisthisme that using an on click event might be best and his if statement looks good.

If you've confirmed that if your logic is working correctly, I'd try using invisible instead of hidden.

Avatar

Level 2

Thanks for your help. Unfortunately, the script did not hide the text field after I clicked another button in the group.

I ended up placing your script in the click event, changing the this.rawValue to "other" (as illustrated below) as I had changed the button value from 8 to other.

In the other buttons click event, I placed the lower script and that hid the text field.

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

   AR05.sfBody.sfRows.txtOther.presence = "visible";

    }

else {

AR05.sfBody.sfRows.txtOther.presence = "invisible";

}

Other buttons

if (this.rawValue == "button value") {

   AR05.sfBody.sfRows.txtOther.presence = "invisible";

}

Avatar

Level 3

Could I also ask if this is possible using a dropdown list instead of a radio button? ie. I have a series of answers ranging from 'yes, right now', 'yes, previously', 'no', 'unknown'

If the user selects either of the yes options I want a table row to appear.

I'm new to this, so I don't know how and where to insert the code for a specific dropdown option rather than a button click.

Avatar

Level 2

Like yourself, I am a newcomer to using LiveCycle and JavaScript (in fact any scripting). I opted for radio buttons in the Form I am designing as it will replace a low use tick box paper Form. Some of those completing it are likley to opt for printing a blank form and completing it by hand.

Someone more knowledgable will hopefully answer you. If I was trying it, I would try mouseUp event or layout:ready in the dropdown's Events and Scripts.

One of the issues I was trying to address, is the user clicking the buuton that displays the text field, entering some info, and then deciding to click on another button. I wanted the text field hidden and cleared.

Interested to see if someone addresses you question.