Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Text Field Control Radio Button

Avatar

Former Community Member

Help PLEASE!

I have a text field [Text1] that I want to control the value of a radio button. I have 13 radio buttons to choose from. For example if I enter "010" into Text1, then I want the corresponding radio button to be clicked. If I enter "011", then the next radio button in the group is checked.

I have this script that fires in the change event of Text1:

if

(form1.Listing.Listing.Text1.rawValue = 010)

{

form1.CheckSheet.CheckSheet.LicType.rawValue

== 1;

}

The name of my RadioButton Group is "LicType". It has 13 radio buttons to choose from. I do not have any warnings show up, so I believe my Syntax is correct so far. I do not know how to proceed from here with the "else" statements.

Anybody PLEASE respond!

thanks

Gene-O

9 Replies

Avatar

Level 7

In formcalc the code would be:

if ($ == 010) then

     form1.CheckSheet.CheckSheet.LicType.RadioButton1 = 1

elseif ($ == 011) then

     form1.CheckSheet.CheckSheet.LicType.RadioButton2 = 1

elseif ($ == 012) then

     form1.CheckSheet.CheckSheet.LicType.RadioButton3 = 1 // etc

endif

Avatar

Level 10

In addition when dealing with text strings, I would put the if statement test condition in quotation marks:

if ($ == "010") then

// etc...

Niall

Avatar

Former Community Member

Also put the code on the exit event of the text field and not the change event. The change event will fire each time you enter a character into the text field. The exit event will fire when you leave the text field and have completed the typing in the field.

Paul

Avatar

Former Community Member

Thank you for your responses, but I'm still missing something! This is what I have:

form1.Listing.Listing.Text1[0]::exit - (FormCalc, client)


if ($ == "010") then
form1.CheckSheet.CheckSheet.LicType.Lounge = 1 elseif ($ == "011") then
form1.CheckSheet.CheckSheet.LicType.Package = 1 elseif ($ == "020") then
form1.CheckSheet.CheckSheet.LicType.Restaurant = 1 elseif ($ == "031") then
form1.CheckSheet.CheckSheet.LicType.ClubI = 1 elseif ($ == "032") then
form1.CheckSheet.CheckSheet.LicType.ClubII = 1 elseif ($ == "040") then
form1.CheckSheet.CheckSheet.LicType.OnOffBeer = 1 elseif ($ == "050") then
form1.CheckSheet.CheckSheet.LicType.OnOffWine[1] = 1 elseif ($ == "060") then
form1.CheckSheet.CheckSheet.LicType.OffBeer[2] = 1 elseif ($ == "070") then
form1.CheckSheet.CheckSheet.LicType.OffBeer[1] = 1 elseif ($ == "140") then
form1.CheckSheet.CheckSheet.LicType.OffWine[2] = 1 elseif ($ == "150") then
form1.CheckSheet.CheckSheet.LicType.OnOffWine[0] = 1 elseif ($ == "160") then
form1.CheckSheet.CheckSheet.LicType.OffBeer[0] = 1 elseif ($ == "220") then
form1.CheckSheet.CheckSheet.LicType.OffWine[1] = 1 elseif ($ == "230") then
form1.CheckSheet.CheckSheet.LicType.OffWine[0] = 1
endif

I don't know what's wrong, but it won't work.

I used the names of the radio buttons ("Lounge", "Package", etc) that I got from the script editor window. I did not assign these names, I don't know where they came from or how to change them. I named the RadioButton Group "LicType". Every time I click on a radio button and try to change the name in the Binding tab, it changes the name of the whole group, not the individual button.

Also, another question I did not originally post. I need to use a wildcard in the script also. For example, the user would not just enter "010", they would enter a string of numbers ("010-123456789". But I want the radio button to fire based on the first three digits ("010") only.

can this be done?

thanks sooooo much!

Gene-O

Avatar

Level 6

Rename the RBs by using the list in the hierarchy pane.  Right click the button in the hierarchy and select rename.

Avatar

Former Community Member

Thanks Paul,

I renamed everything the way I needed. Do you have an answer for why the script won't work and about using a variable?

thanks!

Avatar

Level 6

Here's a possible solution:  javascript on change event

if (xfa.event.newText=="010")
{form1.BodyPage1.RBL.Rb1.rawValue="1"
}

if (xfa.event.newText=="011")
{form1.BodyPage1.RBL.Rb2.rawValue="2"
}

if (xfa.event.newText=="012")
{form1.BodyPage1.RBL.Rb3.rawValue="3"
}

BodyPage1 is the name of my subform

RBL is the radio button list

Rb1 is the name of the radio button

I used the change event so when a user enters the first three digits, the button will turn on.

Not pretty but it works.

Yours should work if you change the value of the radio buttons.  Each button is unique - only the first button will have a value of "1".  The second button will be "2", etc.

Avatar

Former Community Member

Paul,

thanks for the reply!!! I copy/pasted your code into my file, and changed the names. I still don't get it to work!

form1.Listing.Listing.Text1[0]::change - (JavaScript, client)

if

(xfa.event.Text1[0]=="010")

{form1.CheckSheet.CheckSheet.LicType.Lounge.rawValue

="14"

}

 

if

(xfa.event.Text1[0]=="011")

{form1.CheckSheet.CheckSheet.LicType.Package.rawValue

="13"

}

 

if

(xfa.event.Text1[0]=="020")

{form1.CheckSheet.CheckSheet.LicType.Restaurant.rawValue

="12"

}

 

I didn't include every radio button until I figured it out, I just used these 3 to test it.

Any suggestions?

thanks,

Gene-O

Avatar

Level 6

Send me the form if you'd like & I'll take a look

pbeef2000@yahoo.com