Dynamically preselected checkboxes...?
Dear all,
I have given this some thoughts but I'm stuck and need to call in the heavy cavaliry...in other words...please help...
My objective is to display a table with two columns in a page that will allow the user to update the information for a specific product. The table have one coloumn with the name/value and one coloum with the checkboxes. The checkboxes for the value in the database should be preselected.
The name/value and the number of checkboxes are fetched from a table:
---Table attribute_values---
value_id (PK)
attrib_id
attrib_value
example:Table attribute_values
value_id=1
attrib_id=1 (1=size in another table)
attrib_value=37 (size 37)
I have another table that connects products to the attributes:
---Table product_attributes---
value_id=1
username=admin
product_id=104
In this example I have a product that have Size 37 as an attribute and I would like the checkbox for Size 37 to be preselected in the update page for the product.
I choose the product to update in a previous page and get the product_id for this product via GET-method and transfer that ID into a variable in the update-page.
My question to all you intelligent people out there is: How do I accomplish the pre-selected checkboxes? I know that I should use selected="Selected" but should I do a while-loop...or...??? An example would be nice...
I'm grateful for all input.
Thank you,
//Johan Beijar