These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

dropdown list, with mandatory script

manuhunt
Registered: Feb 14 2010
Posts: 9

Hello Im making a form for a children foundation, I work with computers and in media but not with this this is the first time i get my hands into the acrobat livecycle, therefore as you may notice im an absolute amateur for this topic. So here is the thing, im almost done with the form but i have a problem, there is a dropdown list (menu) in which you select what way do you want to make a donation, if you choose the option 1, I want that some other fields get mandatory, but if you choose option 2 or 3 dosnt become mandatory.

I have seen tons of other questions, Ive seen a couple videos, and I downloadied a form that explains the things about dropdown lists, being linked together it is about car parts.

So this is the script I typed

If (this.rawValue == 1)
textfield1.mandatory = "disabled"
else
textfield1.mandatory = "error"

It is in javascript, BUT MY PROBLEM!!! it seems fine, but when i preview it, I click on the options, and the first one seems to work, but then I click on the third option and the mandatory box, is lighted on the textfield... so it dosnt work... I dont know what am I missing or what...

Please dont link me to other pages, im desperate and we dont have the money to pay anybody... so I need to do it myself...

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

your script is faulty.
The expression "If" should be written "if" and you forgot the braces.

It's also better to use the method "xfa.event.newText" instead of "this.rawValue", because it will use the choosen value of the dropdown field immediately.

form1.#subform[0].DropdownList1::change - (JavaScript, client) if (xfa.event.newText == 1){textfield1.mandatory = "error";}else{textfield1.mandatory = "disabled";}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

manuhunt
Registered: Feb 14 2010
Posts: 9
Hello, thanks for your response, but i have a problem with it. With this script even if I change to any value it will light up the madnatory field, instead of only with the value 1. the problem might be something esle but i dont know
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hmmm,

maybe I was misdirected by the script in your post.
There you set the textfield1 to mandatory with every value but 1.

If you only wish to set fields to mandatory, you need the code:
[code][reference syntax].mandatory = "error";[/code]
To set fields to optional then you need:
[code][reference syntax].mandatory = "disabled";[/code]
I corrected the script above so that it will set textfield1 to mandatory only if you choose value 1 from the dropdown field.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs