Copy link to clipboard
Copied
I have created three input textfields for the first, middle and last names in a form and then to pass the input to 3 dynamic texboxes, the middle name is optional so someone might not fill it out and the dynamic textbox would show "undefined", how to make the unfilled input textfield result in a blank/empty dynamic textbox?
Copy link to clipboard
Copied
assume the name of second input text field middlename_txt and the second dynamictextfield is second_txt
if (middlename_txt == undefined){
second_txt.text = "";
}
Copy link to clipboard
Copied
Thank you webqaflash for the code I actually tried the same but it didn't work, it shows nothing even when the middle name is filled out!
Copy link to clipboard
Copied
if (middlename_txt.text == undefined){
second_txt.text = "";
}
Copy link to clipboard
Copied
Yes webqaflash I did the .text and I included (defined) between the double quotes " " but didn't work either..
Copy link to clipboard
Copied
Test the length of the input textfield.before you use it. If it is 0, don't fill in the textfield. if(midName.length > 0) { middleName.text = ...etc }
If you are using the var option of these input textfields, I recommend you don't and just assign instance names to the textfields and use the text property to get/set what they contain. The var element can be troublesome.
Copy link to clipboard
Copied
Hey Ned! I think your right the var thing isn't always a good option, I tried your suggestion like the this:
if (MedIn.length = 0) { MedDyn.text = "" }
else {MedDyn.text = MedInput.text}
Is that right? It didn't work!
Copy link to clipboard
Copied
= is for assignment, == is for comparison
Copy link to clipboard
Copied
Yes Ned I used = for assignment.
But is the code I tried correct?
if (MedIn.length = 0) { MedDyn.text = "" }
else {MedDyn.text = MedIn.text}
I used = instead of > bcoz the the input textfield is unfilled..
Copy link to clipboard
Copied
I haven't looked at the rest, but... no... you haven't used the =/== correctly
if (MedIn.length == 0)
that is not assigning 0, that is comparing to see if the length is zero.
Make sure that you have assigned the instance names properly also (via the Properties panel).
And I wouldn't be assigning "" to the text field... it should already have that value. I would be testing like I showed and only assign a value to the textfield if the length of the input textfield is > 0.
Copy link to clipboard
Copied
I made a big mistake because I made the assigned instances variables in the same time which result was "undefined"!
Thank you so much guys I've learned new things from you ![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more