Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to change "undefined" value?

New Here ,
May 05, 2010 May 05, 2010

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?

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 05, 2010 May 05, 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 = "";

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 05, 2010 May 05, 2010

if (middlename_txt.text == undefined){

     second_txt.text = "";

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 2010

Yes webqaflash I did the .text and I included (defined) between the double quotes " " but didn't work either..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2010 May 05, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2010 May 05, 2010

= is for assignment, == is for comparison

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 2010

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..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2010 May 05, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2010 May 06, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines