ramone_johnny Posted April 24, 2013 Share Posted April 24, 2013 Hey guys, JS has never been my stronger point, so Im after a bit of help with this bit of code. I have an auto suggest field that is populated by user input. When the user has made their final selection, they click on a button to "verify" this input. In simple terms, here's what might be displayed in the auto suggest field upon user selection. INALA, Queensland 4077; ...and then how its passed over to the verification popup window. suburb=INALA%2C%20Queensland%204077%3B I need to somehow split this up so I get each value separately. eg suburb - INALA state - Queensland pcode - 4077 Here's the existing snippet of JS that captures the user input. var suburb = fixField(form.search.value,0,"suburb"); Thanks! Quote Link to comment Share on other sites More sharing options...
.josh Posted April 24, 2013 Share Posted April 24, 2013 If the user is allowed to enter in an arbitrary value, then there's no way to reliably split the data up into those values. If the validation window is ALWAYS passed a value in the exact format of suburb=[suburb]%2C%20[state]%20[pcode]%3B Then you can do something like this: var suburb = "suburb=INALA%2C%20Queensland%204077%3B"; suburb = unescape(suburb).split(/=|,? |;/); suburb will now be: ["suburb", "INALA", "Queensland", "4077", ""] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.