hi i have one checkbox in the form if i check that it should be check in the database field.(in database yes/no field for ckeckbox).what is my problem is every thing is stored except checkbox field.
can u pl correct me?
this is my check box.*******
<input name="current" type="checkbox" id="current" value="">
this is insertion code****** -
<%
-
-
If( (Request("SUBMIT") <> "") and(Request("SUBMIT") = "SUBMIT") ) Then
-
set rstinsert = server.CreateObject("ADODB.Recordset")
-
-
if Request("radiobutton") = "Ms" then
-
salutation = Ms
-
elseif Request("radiobutton") = "Mrs" then
-
salutation = Mrs
-
else
-
salutation = Mr
-
end if
-
-
lastName=request("lastName")
-
middleName=request("middleName")
-
firstName=request("firstName")
-
if Request("rbpostname")= "Jr" then
-
postName=Jr
-
else
-
postName=Sr
-
end if
-
dateBorn=request("dateBorn")
-
dateExpired=request("dateExpired")
-
cemetaryDetails=request("cemetaryDetails")
-
VisitationDetails=request("VisitationDetails")
-
ServicesDetails=request("ServicesDetails")
-
-
if Request.Form("current") = true then
-
rstinsert("current") = "Yes"
-
else
-
rstinsert("current") = "No"
-
end if
-
' dateExpired=Now()
-
sqlinsert = "insert into visitations(salutation,lastName,middleName,firstName,postName,dateBorn,dateExpired,cemetaryDetails,VisitationDetails,ServicesDetails,current) values('" & request("radiobutton") & "','" & lastName & "' , '" & middleName & "', '" & firstName & "','" & request("rbpostname") & "','" & dateBorn & "','" & dateExpired & "','" & cemetaryDetails & "' ,'" & VisitationDetails & "','" & ServicesDetails & "', '" & current & "')"
-
' dbCon.Execute SQL_query
-
rstinsert.Open sqlinsert,dbCon,3,2
-
' response.Write("added")
-
Response.Redirect("visitations.asp?valid=true")
-
'response.write(sqlinsert)
-
end if
-
%>
-
may be i have done mistake in sqlinsert stmt pl correct if u have any idea.currect is the database yes/no field.
5 1115
Hi gudipati,
This question should be in the ASP Forum, not the Articles section (Articles is only to be used for sharing information and not for asking questions).
medicineworker
- if Request.Form("current") = true then
-
rstinsert("current") = "Yes"
-
else
-
rstinsert("current") = "No"
-
end if
These lines -
' dateExpired=Now()
-
sqlinsert = "insert into visitations(salutation,lastName,middleName,firstName,postName,dateBorn,dateExpired,cemetaryDetails,VisitationDetails,ServicesDetails,current) values('" & request("radiobutton") & "','" & lastName & "' , '" & middleName & "', '" & firstName & "','" & request("rbpostname") & "','" & dateBorn & "','" & dateExpired & "','" & cemetaryDetails & "' ,'" & VisitationDetails & "','" & ServicesDetails & "', '" & current & "')"
don't match with these lines. It looks like maybe "rstinsert" is left over from a previous attempt or some other code snippet. This should work: - dim current
-
if Request.Form("current") = true then
-
current = "Yes"
-
else
-
current = "No"
-
end if
[/quote]
hi i tried what u said.still i did't get.
hi i tried what u said.still i did't get.
which line gives you the error?
if Request.Form("current") = true then
Checkboxes do not return a boolean value. They return, by default, a value of "on" if they are checked, and do not return a value if they are not checked. If you set the value attribute of a checkbox, the checkbox will return that value if it is checked, but it still will not return a value if it is not checked.
With that said, you're also setting your checkbox to a value of "" - so you can never tell whether it was checked or not. Since a checkbox that is not checked will not be returned in the Request.Form object - Request.Form("current") will have a value of "" if it is not checked. If the checkbox IS checked, since you are setting its value="" it will also have a value of "" if it IS checked.
Next...
rstinsert("current") = "Yes"
If you are using access, which i'm assuming you are because you referred to it as a yes/no field, this value should be -1 for yes, and 0 for no.
Here is the proper code.
First your checkbox. -
<input type="checkbox" name="current" id="current"/>
-
And the ASP to get the result of the "current" checkbox. -
If Request.Form("current") = "on" then
-
rstinsert("current") = -1
-
Else
-
rstinsert("current") = 0
-
End If
-
And finally a suggestion...
In your access database, if you set the default value of a yes/no field to 0 - when a new record is inserted, the value of this field will be false/0/no etc, unless you specifically tell it that it is true/1/yes etc when you are inserting a new record. This make programming yes/no boxes much easier, and your coding much leaner. -
If Request.Form("current") = "on" then
-
rstinsert("current") = -1
-
End If
-
In other words, if the checkbox is checked - set the yes/no field to yes. If it not checked, don't do anything because the default value of the yes/no field is automatically no, and we don't have to worry about telling it that it is supposed to be false if the checkbox is not checked.
The last part, of course, is merely a suggestion.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Raju V.K |
last post by:
I am developing a PHP-mysql database. It is noted that when the
browser window is refreshed the data is inserted again in the
database. unfortunately there is no unique keys that I can use to...
|
by: Bernhard Schmidt |
last post by:
------=_NextPart_000_0030_01C34C51.B8F4D1A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
hi dear mysql list members
=20
i have setup a mysql...
|
by: Nhat Yen |
last post by:
Hi everyone,
I tried to upload my database to my web host. Nevertheless as they do
not give me enough permission to perform some DTS thus I have to
generate script to do it myself. The problem...
|
by: Patrick Guio |
last post by:
Dear all,
I have some problem with insertion operator together with namespace.
I have a header file foo.h containing declaration of classes, typedefs and
insertion operators for the typedefs in...
|
by: John N. |
last post by:
Hi All,
Here I have a linked list each containing a char and is double linked.
Then I have a pointer to an item in that list which is the current
insertion point.
In this funtion, the user...
|
by: Sam |
last post by:
Hi all
Is it possible to remove/disable automatic new row insertion feature in
datagrid control(last row with * on the left)? I'm implementing a datagrid
table which consists of 4 columns and...
|
by: polocar |
last post by:
Hi,
I have noticed a strange behaviour of CurrencyManager objects in C# (I
use Visual Studio 2005 Professional Edition).
Suppose that you have a SQL Server database with 2 tables called
"Cities"...
|
by: teo |
last post by:
Hallo,
I'm performing a mass insertion
from a text file to a db table
with AdoNet commands, like this:
myCommand.CommandText = "BULK INSERT ..."
from a Win form
no problem
|
by: gudipati |
last post by:
hi i have one checkbox in the form if i check that it should be check in the database field.(in database yes/no field for ckeckbox).what is my problem is every thing is stored except checkbox field....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |