I'm trying to create an app that involves getting a zip code from the user, and then returns the corresponding latitude and longitude coordinates. I created an input text field for the user to enter a 5-digit zip code, and two text fields that display latitude/longitude. I'm pulling data from an xml file that contains nothing but zip codes and coordinates. So far, it runs perfectly for any zip codes not beginning in 0. But if the user were to enter a zip code beginning with one or more zeroes, such as "00987", the number returned is "987". Since that isn't a valid zip code, the latitude and longitude both return 0.
I could post my entire code but I'm not sure that's necessary, it seems more like I just don't understand how input text fields work, or I'm using the wrong method when parsing the user's input. I'm using a number variable for the zip code called myZip, and then using "myZip = parseFloat(zipCodeField.text);" to retrieve the number in the input text field.
Any help is really appreciated, I'm still quite new to Animate and coding so I'm not up to snuff on this kind of stuff yet.
Why on Earth are you using parseFloat? ZIP codes aren't numbers, they're strings.
Well, I had been using a number variable for the zip codes, I see now I should've been using a string variable instead. Last time I did something like this it was with number variables but clearly that wasn't the right way to go about it here. Seems like it's working perfectly now, thanks.