Forum Moderators: open

Message Too Old, No Replies

problem with check box

         

ajifri

11:52 pm on Jan 31, 2003 (gmt 0)

10+ Year Member



Hi,
I have a table with two fields boolean and I want to insert a data to those fields by using check box so I used this page as first page
firtpage.asp
-----------------

<Form name="MyForm" method="POST" action="secondpage.asp">
<table>
<td width="25%" height="23">&nbsp;New Addition</td>
<td width="75%" height="23">&nbsp; <input type="checkbox" name="Additions" value="True"></td>
</tr>
<tr>
<td width="25%" height="23">&nbsp;Special Offer</td>
<td width="75%" height="23">&nbsp;<input type="checkbox" name="Sale" value="True"></td>
</tr>
</Table>
</Form>

-----------------
The secon page is secondpage.asp

<%
MySQL="insert into Product(Additions,Sale) Values(" & request("Additions") & "," & request("Sale") & ")"
conn.Execute(MySQL)
conn.Close
%>

-----------------
the problem is when I check both check box it is work fine, but if I checked one of them it gives me an error cause i left one of them with out value.

Any Idea?

wardbekker

12:11 am on Feb 1, 2003 (gmt 0)

10+ Year Member



ajifri,

<%

Dim newAdditions, isSpecialOffer

IF request("Additions") = "True" Then
newAdditions = true
Else
newAdditions = false
End If

IF request("Sale") = "True" Then
isSpecialOffer= true
Else
isSpecialOffer= false
End If

MySQL="insert into Product(Additions,Sale) Values(" & newAdditions & "," & isSpecialOffer & ")"
conn.Execute(MySQL)
conn.Close
%>

ajifri

12:49 am on Feb 1, 2003 (gmt 0)

10+ Year Member



Thankx wardbekker,
the problem is fixed and the error msg gone,but nothing inserted in the data base even if I check it :(

ajifri

12:51 am on Feb 1, 2003 (gmt 0)

10+ Year Member



sorry it's work great now, really thanx alot