Copy link to clipboard
Copied
Everyone,
I have created a list box that has 5 entries. What I would like to understand is how do I get the value which the user selects. I.E. in the list box, entry 3 has "Other". For the Mouse Up event of the list box, I want to see if the user has selected "Other". If they did, then I will unprotect another field and it becomes a requred entry. If they select something else, then I will set it to protected.
I am sure it is getfield, but unsure of how to structure it. Can someone direct me on doing this? Thanx.
Jerry
Copy link to clipboard
Copied
I made a mistake in my prior reply.
I was using a combox, not a listbox.
The listboxes don't have a an option for custom calculation script. I tested the script now in a listbox and it works fine.
Just don't use it as a mouse-up action.
Do the following:
This is the script I'm using on my end (and is working):
if (event.value == "Other") {
this.getField("txtOther").readonly = false;
this.getField("txtOther").display = display.visible;
this.getField("txtOther").required = true;
} else {
this.resetForm(["txtOther"])
this.getField("txtOther").display = display.hidden;
this.getField("txtOther").required = false;
this.getField("txtOther").readonly = true;
}
Copy link to clipboard
Copied
I think a mouse-up action is not essentially necessary since you can run a script for this purpose as a custom calculation script.
You can run this code directly in the listbox's as custom calculation script.
if (event.value =="Other") {
this.getField("myOtherField").readonly = false;
this.getField("myOtherField").required = true;
} else {
this.getField("myOtherField").readonly = true;
}
Copy link to clipboard
Copied
I moved the code over to a Custom Script and does not work. If I put an "==" in the script and have it in the Mouse Up event, it loops and does not check. This is the code I have in Custom Edit. Can you let me know what is wrong? Thanx.
if (event.target.value = "Other")
{
this.getField("txtOther").readonly = false;
this.getField("txtOther").display = display.visible;
this.getField("txtOther").required = true;
}
else
{
this.resetForm(["txtOther"])
this.getField("txtOther").display = display.hidden;
this.getField("txtOther").required = false;
this.getField("txtOther").readonly = true;
}
Copy link to clipboard
Copied
You moved the script to where?
Are you trying to run the script as a mouse-up action in the listbox field?
Copy link to clipboard
Copied
I moved it to the custom calculation script for this field. I removed the Javascript from the Mouse up Action. I do not have anything under Mouse Action now.
Copy link to clipboard
Copied
Try changing first line from this if (event.target.value = "Other") to this if (event.value == "Other")
Copy link to clipboard
Copied
I made a mistake in my prior reply.
I was using a combox, not a listbox.
The listboxes don't have a an option for custom calculation script. I tested the script now in a listbox and it works fine.
Just don't use it as a mouse-up action.
Do the following:
This is the script I'm using on my end (and is working):
if (event.value == "Other") {
this.getField("txtOther").readonly = false;
this.getField("txtOther").display = display.visible;
this.getField("txtOther").required = true;
} else {
this.resetForm(["txtOther"])
this.getField("txtOther").display = display.hidden;
this.getField("txtOther").required = false;
this.getField("txtOther").readonly = true;
}
Copy link to clipboard
Copied
Works like a charm now. I thank you very much! Have a great weekend.
Jerry
Copy link to clipboard
Copied
You can find out everything you need to know about list programming here:
https://acrobatusers.com/tutorials/change_another_field/
https://acrobatusers.com/tutorials/list_and_combo_in_lc/
https://acrobatusers.com/tutorials/js_list_combo_livecycle/
https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more