You are viewing limited content. For full access, please sign in.

Question

Question

Set Text Field Value Based on Radio Button Value

asked on October 11, 2024

Hello!

Looking for some JavaScript assistance.  I have a radio button with three choices.  I have a separate text field that I want to populate with a 3 digit doc ID code depending on which radio button option is selected. 

Appreciate any help!

0 0

Answer

APPROVED ANSWER
replied on October 13, 2024

Hey Thomas, I don't think JS is necessary here. You can assign a value to a radio button, then use a regular expression to pull the value into a single line field.

 

Here's the RB field (variable as 'Radio_Button):

 

In the single line field, you just use the expression '=Radio_Button'

Selecting a radio button option will produce whatever is in the 'value assigned' of the radio button selected

1 0

Replies

replied on October 14, 2024

Hi Thomas,

I agree with Andrew that you just need a simple formula to get value from the radio button, Andrew shared a sample with the new form, I've also tested on classic form, it is working too.

1 0
replied on February 13

This was greatly helpful, however, I have been trying for the last two days to find how to get either get the Radio Button choice name to populate in a 2nd single line field, or created a 2nd sequence of radio buttons that would auto select based on the selection of the first.

I found this question from Whitney from January 2020, which is exactly what I am trying to accomplish as well, but the answer redirected to something completely off base

https://answers.laserfiche.com/questions/168611/Bring-over-choices-from-a-radio-button-into-another-field-instead-of-the-assigned-value#168647

To Summarize the purpose:

I have a 5 option Radio button with Department names as the "Choice", and the Manager name as the "Value". A single line field with the manager name is populated to send approval emails.

The issue comes in with when we send the email, it addresses the person instead of the Department, so I assume we need a JS to fill the 2nd single line field to display Radio Button selection Choice Name instead of value.

Any assistance would be greatly helpful! Thoughts?

 

0 0
replied on February 13 Show version history

Heya Matthew,

You may be able to use regex for that, too. Something like this could be what you're after:

=IF([department] = "Department 1", "Manager 1 Name",
IF([department] = "Department 2", "Manager 2 Name",
IF([department] = "Department 3", "Manager 3 Name",
IF([department] = "Department 4", "Manager 4 Name",
IF([department] = "Department 5", "Manager 5 Name", "")))))

The singular Single Line field would have the above in its calculation section. It just checks the variable ('department', in this case) and if it aligns with the value it equals to in the IF statement then it displays the manager name. 

Other ways to do it would be if you have a table with the department and the manager in the same line then you could use that in a lookup rule, too. 

Let us know if this isn't what you're after and will try to assist further

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.