Copy link to clipboard
Copied
Hi all,
A issue I have is this.
I do have a choicebox for A, B, C, and D [Choice_01]
Theres a textfield [Output_01]wich is triggered by the choicebox
Last is a textfield [txtResult_1] wich should pull from [Output_01]
To pull I use next script, but it doesn't work and I can't figure out why not.
I hope you see what's wrong. Thanks all.
var f = this.getField("txtResult_1");
if (event.value="Juist") {
f.fillColor = color.green;
f.textColor = color.black;
f.value = "Dit is het juiste antwoord!";}
else if (event.value="Onjuist"){
f.fillColor = color.red
f.textColor = color.yellow;
f.value = "Dit antwoord is niet juist";
}
else{
f.fillColor = color.transparent
f.value = "";}
Do compare values use ==, not only one =
E.g.: if (event.value == "Onjuist")
Copy link to clipboard
Copied
Do compare values use ==, not only one =
E.g.: if (event.value == "Onjuist")
Copy link to clipboard
Copied
Hallo Berndt,
Thanks for the input. Unfortunally it doesn't work.
If there's no value the textfield is green with the corresponding text.
On output "Onjuist" it remains green with corresponding text, not red with the corresponding text.
I would have it blanc wenn no output is there as you se at he end in the script.
I do use now and there's no pagescript or so.
var f = this.getField("txtResult_1");
if (event.value=="Juist") {
f.fillColor = color.green;
f.textColor = color.black;
f.value = "Dit is het juiste antwoord!";}
else if (event.value=="Onjuist"){
f.fillColor = color.red
f.textColor = color.yellow;
f.value = "Dit antwoord is niet juist";
}
else{
f.fillColor = color.transparent
f.value = "";}
Copy link to clipboard
Copied
I'm assuming you are checking the console and there are no errors. Use app.alert to see which of the three { ... } sections is run. Often there are surprises. Also use app.alert to check the value of f.
Copy link to clipboard
Copied
Where did you place the code? Are there any error messages in the JS Console when you use it?
Copy link to clipboard
Copied
Thanks for the answers and help.
No errors at all.
Choicebox is the box in which you choose between the choices I filled in. Is it called drop down list?
The code is placed in [txtResult_1] [confirm] [ adjusted validations script]
(I do hope the English is ok, my DC is in Dutch ;).
Copy link to clipboard
Copied
Check the JS Console (Ctrl+J) after changing the value of the field.
Copy link to clipboard
Copied
What does you mean with "choicebox"?
Copy link to clipboard
Copied
drop down box
Copy link to clipboard
Copied
You must use the script as validation of the dropdown list.
Or want you validate the value of the text field?
Copy link to clipboard
Copied
yesss!
Thanks all for the help.
Last i did as bernd advised and used the script to push [txtResult_1], that works fine and even
showd me that the field [Output_01] here has no use.
Splendid! The choice now directly pushes the color and text in [txtResult_1]
Thanks all for this!