Click to See Complete Forum and Search --> : Help with a select box
davewil
07-22-2003, 11:28 AM
I have a select box that pulls in data from a table in MySQL using php. The select box works fine but what I want to do is when a user clicks an account in the select box, I want to display the account description next to it. Everbody that I talk to says it should be done with javascript, but I cant figure out how to do it. I get the data using PHP and store the account numbers and description in a array. Does anybody know how to accomplish this. Please help
Khalid Ali
07-22-2003, 11:35 AM
if the data is already in javascript array thenyour work is almost doen..get the selectedIndex value of the list box and search the array that matches that index value and print the description for that index....
davewil
07-22-2003, 12:01 PM
I have not worked with javascript very much is there any way you can give an example
Khalid Ali
07-22-2003, 12:31 PM
for that show me how do you have the data in the array...(accounts and description)
davewil
07-22-2003, 12:47 PM
I have attached a text file hopefully it will help. I use php to pull the data and store it into a associative array
Khalid Ali
07-22-2003, 12:55 PM
hunmm..well how about posting the html code instead of php...or may be a link pointing to this page...
davewil
07-22-2003, 01:16 PM
here is the html code that it printed
<select name='acctnum' id='acctnum'>
<option value="1260">1260</option>TEST1
<option value="1311">1311</option>TEST2
<option value="1316">1316</option>TEST3
<option value="1340">1340</option>TET4
<option value="1350">1350</option>TEST5
</select>
As you can see it prints the description but it won't show up on my page I don't know what to use to or how to display the description(textbox,input box, etc...)
Khalid Ali
07-22-2003, 01:45 PM
Ok I think I know what you are talking about..what you can do is in your php where you are creating the list box you can create
<input type="text" value"<$array[index]"/>
where index should point to the array index that contains description