Forum Moderators: open

Message Too Old, No Replies

dynamically creating a textfield value

         

ahmed24

9:26 am on Aug 24, 2009 (gmt 0)

10+ Year Member



hey everyone,

i have some data that i want to put in some sort of javascript array. the data is basically addresses which have address ID's which is basically like this:

ID: 70 => Adresss: 123 StreetName, ZIP1
ID: 71 => Adresss: 456 StreetName, ZIP2

I want to be able to somehow store that in a javascript array and then be able to use a textfield with javascript that searches through the arrays to display the matches and once the match is selected i need it to create a textfield with the value of the ID like this:

<input type=text name=address_id value=70>

any suggestions on how i can do this would be appreciated.

thanks

whoisgregg

2:55 pm on Aug 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey ahmed24,

Could you post what code you've attempted so far?

ahmed24

6:04 pm on Aug 24, 2009 (gmt 0)

10+ Year Member



thanks for your reply.

well basically what i've done so far is create an array with the array index as the ID value of the address, like this:

var array=new Array();
array[70]="Address 1, ZIP 1";
array[71]="Address 2, ZIP 2";
array[72]="Address 3, ZIP 3";
array[73]="Address 4, ZIP 4";

with the above i am able to display the ID value of an address by defining the address like this:

var index = array.indexOf("Address 4, ZIP 4");
document.write("<input type='text' name='address_id' value='"+index+"'>");

the next few things that i need help in doing is being able to search for a zip code for example and it would list matches and i select the match i want and that will basically the value of the input field.

any ideas?

thanks

ahmed24

7:31 pm on Aug 25, 2009 (gmt 0)

10+ Year Member



any ideas anyone? i want basically have a html textfield that i type a search criteria of the address and then when i click a button, the javascript dynamically gets all matches if and clicking on the match needs to set value of the text field called address_id