Hello everyone,
I am working with the display property for the first time, and it's working opposite of what I expected. This is my function:
function RadioButtonRequired() { //assign a variable for the Radio Button var rb2=getField("Slide"); //assign variables for the combobox fields var s1=getField("11_6"); var s2=getField("11_7"); /*test the radio buttons--if yes is selected, comboboxes become visible*/ if(rb2.value == "Yes") { s1.display=display.visible; s2.display=display.visible; } else { s1.display=display.hidden; s2.display=display.hidden; } }
I have an Action on each Radio Button to run the JavaScript RadioButtonRequired();.
When I test it by clicking on the Yes Radio Button, the fields become hidden instead of visible. When I click the No Radio Button, the fields become visible.
Can anyone tell me what I'm missing?
Thanks,
Lisa Gielczyk
The issue is that the value is following the action, rather that Action following the value change. So the script must be being called with the wrong trigger.
Mouse Down preceeds the radio button value being changed. You can test this out by putting the cursor over the radio button pressing down on the mouse button, do not let up on the mouse. Is your action happening? Did the radio button value change? Now move the cursor off the radio button and lift up on the mouse button. Try this again but lift up on the mouse while it is over the radio button. See the difference? The radio button value only changes on the mouse up.
All changes are made only on Mouse Up, so this is where the script should be.
On another note: You've done this correctly in one sense, by using a document level function. But it's bad form to use "getField()" to acquire field the script is being called for. Instead, use "event.target". So your "if" would look like this:
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script