471,582 Members | 1,361 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

if checkbox true insert value problem ?

Fary4u
273 100+
Hi

is any body know where is actual problem is coz it's look me some problem ?
to insert value into the MS ACCESS DATABASE after the value is true form html


Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="checkbox" name="1" value="1">
  3. <input type="checkbox" name="2" value="2">
  4.  
  5. st1 = Request.Form("1")
  6. st2 = Request.Form("2")
  7.  
  8. If st1 = "True" Then
  9.             sql = "INSERT INTO Search(v) values " _
  10.                       & "( '" & st1 & "')"
  11.             response.write "insert value 1"
  12. end if
  13. else If st2 = "True" Then
  14.             sql = "INSERT INTO Search(v) values " _
  15.                       & "( '" & st2 & "')"
  16.             response.write "insert value 2"
  17. end if
  18.  
  19.  
but after true value it has to be insert the value into the specificed field ?
Oct 15 '07 #1
1 2749
markrawlingson
346 Expert 100+
2 problems here..

1. Checkboxes, by default, return a value of "on" if they are checked, and do not return any value if they are not checked. However, since you are supplying a value for your checkboxes, they will return that value if they are checked, rather than "on", and will not return a value if they are not checked. So first of all you are checking to see if the checkboxes are "true" which they aren't.

Second thing is that your if.. else.. statement is wrong.

try the following..

Expand|Select|Wrap|Line Numbers
  1. <input type="checkbox" name="1" value="1">
  2. <input type="checkbox" name="2" value="2">
  3.  
  4. st1 = Request.Form("1")
  5. st2 = Request.Form("2")
  6.  
  7. If st1 = "1" Then
  8.             sql = "INSERT INTO Search(v) values " _
  9.                       & "( '" & st1 & "')"
  10.             response.write "insert value 1"
  11. end if
  12. If st2 = "2" Then
  13.             sql = "INSERT INTO Search(v) values " _
  14.                       & "( '" & st2 & "')"
  15.             response.write "insert value 2"
  16. end if
  17.  
hope this helps.
Sincerely,
Mark
Oct 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by nicholas | last post: by
1 post views Thread by Ramakrishnan Nagarajan | last post: by
34 posts views Thread by clinttoris | last post: by
5 posts views Thread by =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.