Skip to main content
Known Participant
May 5, 2010
Question

How to change "undefined" value?

  • May 5, 2010
  • 3 replies
  • 1099 views

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?

This topic has been closed for replies.

3 replies

DawnsGuyAuthor
Known Participant
May 6, 2010

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

Ned Murphy
Legend
May 5, 2010

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.

DawnsGuyAuthor
Known Participant
May 5, 2010

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!

Ned Murphy
Legend
May 5, 2010

= is for assignment, == is for comparison

webqaflash
Inspiring
May 5, 2010

assume the name of second input text field  middlename_txt and the second dynamictextfield is second_txt

if (middlename_txt == undefined){

     second_txt.text = "";

}

DawnsGuyAuthor
Known Participant
May 5, 2010

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!

webqaflash
Inspiring
May 5, 2010

if (middlename_txt.text == undefined){

     second_txt.text = "";

}