DYNAMIC LISTBOX HELP
Posted: Mon Sep 28, 2009 7:54 am
Hi,
Can somebody please give me some advise on how to get the correct syntax for what I am trying to do, if it's even possible the way I have it...
This is what I am trying to do! I have a listbox with products the user can select, the user selects the item he wants, then hits the submit button, the value of the selected item gets saved to a mysql database as either "image1", "image2", etc, etc. When the form is reloaded, I would like to have the listbox value read back the written value of either "image1", "image2", etc from the database, and then use it to automatically select the correct listbox item when the form is loaded next time.
The onChange="loadproduct1(this) event for this listbox just calls a function which changes the images according to the selected item in the listbox, those image paths are then saved to the database as well! I have tried several ways of trying to manipulate the syntax I have below, but I just can't seem to find the correct syntax. If anybody knows or has seen something similar to what I am trying to do, could you please give me a hand on this - I am running out out ideas!
=========================================
This is what I am using, a normal listbox
=========================================
============================================================================
Below is what I would like to use, but I can't figure out the correct syntax..
============================================================================
Any help on this will be very much appreciated...
Thanks
Grant
Can somebody please give me some advise on how to get the correct syntax for what I am trying to do, if it's even possible the way I have it...
This is what I am trying to do! I have a listbox with products the user can select, the user selects the item he wants, then hits the submit button, the value of the selected item gets saved to a mysql database as either "image1", "image2", etc, etc. When the form is reloaded, I would like to have the listbox value read back the written value of either "image1", "image2", etc from the database, and then use it to automatically select the correct listbox item when the form is loaded next time.
The onChange="loadproduct1(this) event for this listbox just calls a function which changes the images according to the selected item in the listbox, those image paths are then saved to the database as well! I have tried several ways of trying to manipulate the syntax I have below, but I just can't seem to find the correct syntax. If anybody knows or has seen something similar to what I am trying to do, could you please give me a hand on this - I am running out out ideas!
=========================================
This is what I am using, a normal listbox
=========================================
Code: Select all
<select size="1" name="product1" onChange="loadproduct1(this)" id="product1">
<option value="Image1">iPhone 3G S - 16 Go
<option value="Image2">HTC Hero
<option value="Image3">Canon EOS 500D Kit
<option value="Image4">PlayStation 3
</select>============================================================================
Below is what I would like to use, but I can't figure out the correct syntax..
============================================================================
Code: Select all
<select size="1" name="product1" onChange="loadproduct1(this)" id="product1">
<option value="image1" <? if($form->value("product1") == 'image1'){ echo 'selected="selected"'; } ?>>iPhone 3G S - 16 Go
<option value="image2" <? if($form->value("product1") == 'image2'){ echo 'selected="selected"'; } ?>>HTC Hero
<option value="image3" <? if($form->value("product1") == 'image3'){ echo 'selected="selected"'; } ?>>Canon EOS 500D Kit
<option value="image4" <? if($form->value("product1") == 'image4'){ echo 'selected="selected"'; } ?>>PlayStation 3
</select>Thanks
Grant