How to insert the checkbox values into database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JSharma
    New Member
    • Nov 2010
    • 1

    #1

    How to insert the checkbox values into database?

    Hii Everyone

    I am having a problem while inserting the checkbox values into database after posting. I am actually getting the Checkbox fields from Database .Now I want to insert the Checked field values into Database from next page.Please help me how to Loop and get the Check box values in a String.

    I am also passing a Hard Coded Text (A and E) along with the Chkbox Value.How do i split it in the Loop and insert Application Code and the hard coded text as Seperate Values....

    Code:
    <table border="1" width="85%" cellspacing="0" cellpadding="0">
    
        <td width="50%" align="center"><b>Application Name</b></td>
        <td width="26%" align="center"><b>Maker</b></td>
        <td width="24%" align="center"><b>Authoriser</b></td>
      </tr>
                      <%
             SFT = "select app_id,app_name from mstrdb.app_mstr where app_id in (select app_id from mstrdb.APP_BRNCH_ACCESS_MSTR where (using_sol='" & emp_brnch & "' or using_sol='ALL')) and status='Y' order by app_name"
         	set objrs1= objConn.execute(SFT)     
    		'response.write SFT
    
    			Dim i
    			Dim tot1
    			Dim totval
                      
    				i = 1
    
    				Do WHILE NOT objrs1.EOF
    				totval = int(objrs1.RecordCount)
    				tot1 = 0
    
    
    			
    			%>
    
    
      <tr>
        <td width="50%"><% = ucase(objrs1(1)) %></td>
        <td width="26%" align="center">
        <input type="radio" value="<%=objrs1(0) & "-E"%>" name="cb<%=i%>"></td>
        <!--input type="text" name="cb<%=i%>" value="<%=objrs1(0) & "-E"%>"></td-->
        <td width="24%" align="center"><input type="radio" name="cb<%=i%>" value="<%=objrs1(0) & "-A"%>"></td>	
        <!--input type="text" name="<% =i%>" value="<%=objrs1(0) & "-A"%>"></td-->
        
      </tr>
    
    			<%
    				i = i + 1
    			objrs1.MoveNext
    			Loop
    			%>
    </table>
    Last edited by jhardman; Nov 21 '10, 04:26 PM. Reason: Added code tags. Please use [code] and [/code] tags in the future.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    It wasn't clear from your post what problem you are having. One common problem I see is having a checkbox return a "yes" value, and needing this stored as "true" or 1 in a db. If that's the problem, try printing out exactly what the form returns like this:
    Code:
    for each x in request.form
       Response.write x & ": " request.form(x) & "<br>" & vbnewline
    Next
    then you can check whether the form data is in the best format to put in your db.

    Let me know if this answers your question.

    Jared

    Comment

    Working...