Expand my Community achievements bar.

SOLVED

Capturing user response based on radio button

Avatar

Former Community Member

I am trying to capture user response based on yes or no reply to a required radio button.  If they answer yes, they need to provide details.  The radio button values are N and Y, nothing listed under item, the captions are turned off. I used the LiveCyclePopUp.pdf sample by George Kaiser as a go-by and modified for my radio button/text field name and added the visible/invisible, but no luck.

Here is what I'm trying, but it's not working, nothing happens when I click either yes or no, am using javascript. 

Once this is working right, if possible, I would like to add to my submit button a double check to make sure if this radio button answer is Y and the text box is null, go back and provide the answer, but the most important part is to get this part working.  Any ideas what I'm missing?  Thank you!

switch (this.rawValue)

{

    case "Y":

    Response25AY.presence = "visible";

    Response25AY = xfa.host.response("Please enter "YES" details (date, injury details, corrective action) below", "Q25A YES DETAILS", "Please enter "YES" details (date, injury details, corrective action) here . . . ");

    break;

   

    case "N":

    Response25AY.presence = "invisible";

    break;

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Firstly, the syntax is JavaScript, so when setting the Response25AY, you would need to include .rawValue:

Use of quotation marks within the script will give a syntax error (around the YES).

A small note: I would not duplicate the question as a default value. It does not really add value.

So this should be closer:

Response25AY.rawValue = xfa.host.response("Please enter YES details (date, injury details, corrective action) below", "Q25A YES DETAILS");

Can you check the relative reference from the radio button group to the Response25AY object. It may be that the reference in the script is not full enough and is incomplete.

Also I would place this script in the click event of the radio button exclusion group.

Lastly, check the JavaScript Console (Control+J) when previewing the form, for errors.

Hope that helps,

Niall

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

Firstly, the syntax is JavaScript, so when setting the Response25AY, you would need to include .rawValue:

Use of quotation marks within the script will give a syntax error (around the YES).

A small note: I would not duplicate the question as a default value. It does not really add value.

So this should be closer:

Response25AY.rawValue = xfa.host.response("Please enter YES details (date, injury details, corrective action) below", "Q25A YES DETAILS");

Can you check the relative reference from the radio button group to the Response25AY object. It may be that the reference in the script is not full enough and is incomplete.

Also I would place this script in the click event of the radio button exclusion group.

Lastly, check the JavaScript Console (Control+J) when previewing the form, for errors.

Hope that helps,

Niall

Avatar

Former Community Member

Thank you, Niall, that did the trick.  I am not sure what you meant by relative reference maybe not being full enough or complete, so sorry.  However, making the changes you posted fixed the problem, and you are right, repeating the question as a default value doesn't add much value.  Thank you again for your help, this is great.

Avatar

Former Community Member

I do have one more question, and that is on the formatting of the text box for the response.  Most of the responses will be a small paragraph, I'll be importing it into a memo field in Access, and the dialog pop-up seems to accept large text amounts ok, but the text box (it's set to multi-lines, rich text), doesn't seem to wrap the text and have scrollbars if the text extends, it only shows the first line (text box height is 1"), and if I click into the text box (it's on the far right side of page since it is only visible if they check yes to a fatality or disabling injury), the text box extends all the way to the right of the screen/form.  If I'm stuck with this setting, that will be ok since the answers all get pulled into Access, but if there is a way to lock the size of textbox, get the text to wrap, and have scrollbars if it extends past visible area, that would be awesome.  Thank you.

EDIT - DISREGARD, sorry, didn't see I had set the width to 'expand'.  Unchecked and all is well.

Message was edited by: sparrowce

Avatar

Level 10

Glad you got it sorted, but in any case have a look at this example for various options getting fields dynamic: http://assure.ly/g80MVY. It might help in the future.

Also, having the correct relative reference to objects is very important. See discussion and example here: http://assure.ly/kUP02y.

Good luck,

Niall

Avatar

Former Community Member

Wow. thank you for those links, yes, I think they sure will help in the future, excellent!