Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Checklist Form

Status
Not open for further replies.

amclendon

MIS
May 13, 2003
1
US
I have a checklist form with 35 checkboxes so a user can check-off assignments as he finishes them on a project. How can I setup the page so that when the user submits the changes, those boxes will still be checked when he returns to the checklist?
 
r u saving the information to a database? if yes it can be done.

Known is handfull, Unknown is worldfull
 
Assuming you do have this set up in a database, you should have an assignments table that holds all of the assignments. You should be able to add a single column to it, something like status. I would suggest using either a boolean value type or tiny int for this field.

When you load the list of assignments from the database, you have a couple options on how to keep track of which checkbox belongs to whom. If the chekbox is the only editable field on that page I would suggest having two inputs, one for the id of the assignment and, of course, the checkbox.

Your loop would look something like this:
Code:
Do Until rs.EOF
   'some random fields like name and something else
   Response.Write &quot;<tr><td>&quot; & rs(&quot;assgn_name&quot;) & &quot;</td><td>&quot; & rs(&quot;assgn_another_field&quot;) & &quot;</td>&quot;
   
   'your hidden field for the id and the checkbox
   Response.Write &quot;<td><input type=&quot;&quot;hidden&quot;&quot; name=&quot;&quot;a_id&quot;&quot; value=&quot;&quot;&quot; & rs(&quot;assgn_id&quot;) & &quot;&quot;&quot;><input type=&quot;&quot;checkbox&quot;&quot; value=&quot;&quot;done&quot;&quot; name=&quot;&quot;chk_&quot; & rs(&quot;assgn_id&quot;) & &quot;&quot;&quot;&quot;
   'note the checkbox tag is still open
   If rs(&quot;assgn_status&quot;) = True   'assume in this case we decided True means done
      Response.Write &quot; checked&quot;
   End If
   'close the checkbox regardless of whether we checked it or not, finish the row
   Response.Write &quot;></td></tr>&quot;

   rs.MoveNext
Loop

Now that would take care of reading the values from the database. When they submit the form that the above rows are in (after checking some boxes of course) then what the next page receives will be a single variable named a_id with a comma seperated list of assignment id's and a bunch of checkbox variables for the checkboxes that were checked. To read back which ones have which status, we can split the list of id's and use that to check if the status has a value or not:
Code:
Dim idlist
idlist = Split(Request.Form(&quot;a_id&quot;), &quot;, &quot;) 'note we split on comma space, browsers place a comma space between each value just to make life difficult for us :)

Dim ctr
For ctr = 0 to UBound(idlist)
   If Request.Form(&quot;chk_&quot; & idlist(ctr)) <> &quot;&quot; Then
      'this checkbox has a value, so it is complete
   Else
      'this checkbox doesn't have a value, so it is incomplete
   End If
Next

You could set a variable inside the if statement for the status of each assignment and execute an SQL statement right afterwards in order to update the entry in the database, or you could create another array before the loop and redim it to UBound(idlist) and set each entry relative to the entry in the idlist array, then loop through both.

Hope this helps as a starting point,

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top