How to update only records ticked off with checkbo

Results 1 to 3 of 3

Thread: How to update only records ticked off with checkbo

  1. #1
    Join Date
    Dec 1969

    Default How to update only records ticked off with checkbo

    For my web site, users can create a list of contacts (fName, lName, emailaddress, stored in one table of the databse). Users should then be able to view all their contacts, and tick checkboxes next to the ones that are to be added on to a "share" list (forn a form), which requires inserting their data in another table.<BR><BR>A recordset query gets the initial contact data and displays it with a checkbox in front of it, and a hidden field to store the values for the form. All of this has a repeat region to show all contacts. When the submit button is pressed, an insert record then inserts the data into the next table, but how do I limit the inserts to the ones ticked off?<BR><BR>I tried creating a variable which gets the value of the checkbox, and only inserts if checked, but where should the variable be declared and the value checked?<BR><BR>I&#039;d be grateful for any help or tips in this matter..<BR><BR><BR>Bendik..

  2. #2
    Join Date
    Dec 1969

    Default One easy way is to name your

    form variables with a consistent naming convention and pass yourself a hidden variable with the total number of recs.<BR><BR>So for example your form might look like the following:<BR><BR>&#060;form method="post" action="whatever.asp"&#062;<BR>&#060;input type="hidden" name="totrecs" value="5"&#062;<BR><BR>&#060;input type="checkbox" name="ck_share1" value="Y"&#062;<BR>&#060;input type="hidden" name="key1" value="6"&#062;<BR><BR>&#060;input type="checkbox" name="ck_share2" value="Y"&#062;<BR>&#060;input type="hidden" name="key2" value="9"&#062;<BR><BR>etc......<BR>&#060;/form&#062;<BR><BR>Then on processing page you would simply loop thru the total recs and check the current checkbox value:<BR><BR>intTotalRecs = request.form("totrecs")<BR><BR>for i = 1 to intTotalRecs<BR> strCurrCkVal = request.form("ck_share"&i)<BR><BR> if strCurrCkVal = "Y" then<BR> your insert stuff<BR> end if<BR>next<BR><BR>Make sense?<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: How to update only records ticked off with che

    This should be in the asp forum but here goes......<BR><BR>name your checkbox uniquely, i.e.<BR>&#060;input type=checkbox name=chk00123 value=Y&#062;<BR><BR>where 00123 is the id of the "contact" - u could use anything unique.<BR><BR>I&#039;m assuming there is one button that updates them all (otherwise it&#039;d be a bit of a no-brainer)<BR><BR><BR>you must, at some point, loop through the records you have, & generate an insert statement, so, it is at this point that you do<BR><BR>---------------------<BR>-----my for loop<BR>---------------------<BR><BR>for blah = blah to blah<BR> <BR> val = whateveryouruniquekeyis<BR> if request.form("chk" & val) = "Y" then<BR> &#039;generate the insert statement<BR> end if<BR><BR>next<BR><BR><BR>something like that???<BR>cp<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts