Help with a for .. next loop for multiple check bo

Results 1 to 5 of 5

Thread: Help with a for .. next loop for multiple check bo

  1. #1
    Salli Conway Guest

    Default Help with a for .. next loop for multiple check bo

    Can anyone help?<BR>I have a page which shows three sets of check boxes and uses a for next loop to insert the values into a SQL database.<BR>(It shows skills people have) I now need to add a drop down menu to allow people to record their level for each skill (basic, intermediate, etc). I&#039m not sure how to deal with the 2 sets of form objects at once within my loop. This is my loop, which is falling over on getting the values from the drop downs<BR><BR>&#060;%For Each ObjItem in Request.Form%&#062;<BR> &#060;%If left(ObjItem,3)="key" then%&#062;<BR> &#060;%If Request.form(ObjItem).count&#062;1 then%&#062; <BR> <BR> &#060;%For intloop=1 to Request.Form(ObjItem).Count%&#062;<BR> &#060;%sql="INSERT INTO " & Request("Table") & "("&Right(ObjItem,Len(ObjItem)-3)&",CandidateKey,SkillSetKey, SkillLevel) SELECT "&Request.form(ObjItem)(intloop)&" as "&Right(ObjItem,Len(ObjItem)-3)&", "&Session("CandidateKey")&" as CandidateKey, 1 as SkillSetKey, "&request("keySkillLevel")&" as SkillLevel"%&#062;<BR> &#060;%=sql%&#062;<BR> &#060;%DBConn.execute(sql)%&#062; <BR> &#060;%next%&#062;<BR> &#060;%end if%&#062;<BR> &#060;%end if%&#062;<BR>&#060;%next%&#062;<BR><BR><BR>I&#039m having trouble inserting the SkillLevel field as I&#039m not sure how to get its value out into my SQL. Anyone have any ideas or able to point me to a site with some advanced form field handling info?<BR>

  2. #2
    Sateesh Guest

    Default Not a big deal

    I have attached a model script, i assumed the name of the check boxes to be checkbox1 ,..2 ,..3 and the dropdown boxes to be select1, ..2, ..3 change the response.write into the query to insert data into the database instead of showing it<BR><BR><BR><BR>dim count<BR>Count = 1<BR><BR>do until count = 4<BR> if Request.Form ("checkbox" & count) &#060;&#062; "" then<BR> if Request.Form ("select" & count)&#060;&#062; "0" then<BR> Response.Write count & ":" & Request.Form ("Select" & count) & "<BR>"<BR> end if<BR> end if<BR> count = count + 1<BR>loop

  3. #3
    salli Guest

    Default RE: Not a big deal

    Thanks a lot Sateesh - I&#039ll give this a go

  4. #4
    salli Guest

    Default RE: Not a big deal

    This didn&#039t get me any further I&#039m afraid, although I&#039m really grateful for your help. Am I doing something wrong?<BR>My first group of checkboxes is Checkbox1, first group of selects Select1, second group of checkboxes Checkbox2, second group of selects Select2, etc, as you said.<BR><BR>However when I post my form to your code I get this (one for each check box and select box chosen):<BR><BR>1:Basic, Basic, Null, Null, Null, Null <BR><BR>There are six records in my first group of checkboxes/selects, hence the six items after the colon above.<BR><BR>However, what I need to see is just the select value matching that checkbox ie.<BR><BR>1: Basic<BR>1: Basic<BR>1: Null etc.<BR><BR>Any ideas how I can isolate this?

  5. #5
    salli Guest

    Default RE: Not a big deal

    Got this one sorted now. Thanks.

Posting Permissions

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