Dynamic Checkboxes and ASP Split Function - can anyone help?
Posted on 2004-04-16
I have a form which contains a series of checkboxes. All the checkboxes have the same name but carry different values. The checkboxes are created dynamically and their values are taken from a table in a database - the number of checkboxes shown in the form relates to the number of entries in the table column in the database.
When the user selects any number of checkboxes and submits the form their values are then added inside another table as a comma delimated string (apples, pears, oranges, etc).
On editing this form I have looped through the initial number of checkboxes for the form with no problems:
<% Do While Not rsMat.EOF%>
<input type="checkbox" name="ProdMat" value="<%=rsMat.Fields("rbFruit").Value%>"><%=rsMat.Fields("rbFruit").Value%>
but then I need to have checked the boxes which were saved by the user, and this is where I am stuck.
I have a feeling that the Split() function comes into this solution but am unsure how this would integrate so that it will know which boxes should be ticked when it loops through it.
I know this can be done by passing values between two <SELECT> boxes but in this instance I'd rather use checkboxes if pos.
Many thanks in advance.