Welcome to Dream.In.Code
Getting Help is Easy!

Join 98,764 Programmers for FREE!. Ask your question and get quick answers from Dream.In.Code experts. There are 1,038 online right now! We're the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert

Register to Make This Box Go Away!


Checkboxes

2 Pages V  1 2 >  
Reply to this topicStart new topic

Checkboxes

Dark_Light
post 6 May, 2008 - 02:16 PM
Post #1


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


How do I get a value from a checkbox that tells if it's checked or not that I can put in a database?

I'm working with asp

This post has been edited by Dark_Light: 6 May, 2008 - 02:29 PM
User is offlineProfile CardPM

Go to the top of the page


jayman9
post 6 May, 2008 - 04:14 PM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,044



Thanked 12 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


The Checked property will return true if it is checked otherwise it will return false.

Example Usage:
CODE

If (CheckBox1.Checked == True)
{
     //do something here
}
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 6 May, 2008 - 09:28 PM
Post #3


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


Can't I use a request.form() to get the value?
User is offlineProfile CardPM

Go to the top of the page

thor78
post 6 May, 2008 - 10:24 PM
Post #4


D.I.C Head

Group Icon
Joined: 6 May, 2008
Posts: 96



Dream Kudos: 50
My Contributions


The beauty of asp.net is that you can access the control's properties almost immediately with the code behind.

You can use request.form(), but Checkbox1.Checked is much much easier!
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 6 May, 2008 - 11:36 PM
Post #5


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


how do I use this checkbox1.checked then?
User is offlineProfile CardPM

Go to the top of the page

JasonMcAuley
post 7 May, 2008 - 05:14 AM
Post #6


D.I.C Head

**
Joined: 10 Apr, 2008
Posts: 134


My Contributions


QUOTE(Dark_Light @ 6 May, 2008 - 11:36 PM) *

how do I use this checkbox1.checked then?


Jayman gave you the answer above.


CODE


if checkbox1.checked = true then

//Do database work

end if





the .checked property of the checkbox returns the current checked status of the control (true when it is checked).
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 7 May, 2008 - 06:24 AM
Post #7


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


oh...

This post has been edited by Dark_Light: 7 May, 2008 - 06:25 AM
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 7 May, 2008 - 06:38 AM
Post #8


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


what does it mean when it gives me this error:



Kompileringsfel i Microsoft VBScript fel '800a0400'

Programsats förväntas.

/browserGame/saveInfoALT.asp, rad 64

End if
^
User is offlineProfile CardPM

Go to the top of the page

JasonMcAuley
post 7 May, 2008 - 07:20 AM
Post #9


D.I.C Head

**
Joined: 10 Apr, 2008
Posts: 134


My Contributions


What is the english translation of that error message?
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 7 May, 2008 - 07:39 AM
Post #10


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


no Idea... I can e-mail you the script so you can look at it?
User is offlineProfile CardPM

Go to the top of the page

JasonMcAuley
post 7 May, 2008 - 07:44 AM
Post #11


D.I.C Head

**
Joined: 10 Apr, 2008
Posts: 134


My Contributions


Just post your code in this thread.
User is offlineProfile CardPM

Go to the top of the page

Dark_Light
post 7 May, 2008 - 07:48 AM
Post #12


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 10


My Contributions


This is the code that is giving me that error:

CODE
<%
option explicit
%>
<!-- #INCLUDE FILE="connect.asp" //-->
<%
dim info
dim userAge
dim userGender
dim userOrientation
dim showAge
dim showGender
dim showOrientation
dim userLname
dim showLname
dim objconnection
dim SQLQuery
dim RSuser

userAge = request.form("age")
userGender = request.form("gender")
userOrientation = request.form("orientation")
userLname = request.form("lastname")
showAge = request.form("showage")
showGender = request.form("showgender")
showOrientation = request.form("showorientation")
showLname = request.form("showlastname")
info = request.form("info")

'*** Skapa ett objekt för databasanslutning
Set objConnection = Server.CreateObject("ADODB.Connection")

'*** Anslut till databasen
objConnection.Open strConnect '*** Variabeln strConnect hämtas från include-filen

'*** Definiera SQLFråga
SQLQuery = "UPDATE users SET userAbout = '"&info&"' userAge = '"&userAge&"' userGender = '"&userGender&"' userOrientation = '"&userOrientation&"' userLname = '"&userLname&"' showAge = '"&showAge&"' showGender = '"&showGender&"' showOrientation = '"&showOrientation&"' showLname = '"&showLname&"'WHERE userID = "&Request.Cookies("Database")("userID")&""

if showage.checked = true then

SQLQuery = "UPDATE users SET showAge = '"&yes&"' WHERE userID = "&Request.Cookies("Database")("userID")&""

else do

SQLQuery = "UPDATE users SET showAge = '"&no&"' WHERE userID = "&Request.Cookies("Database")("userID")&""


if showgender.checked = true then

SQLQuery = "UPDATE users SET showGender = '"&yes&"' WHERE userID = "&Request.Cookies("Database")("userID")&""

else do

SQLQuery = "UPDATE users SET showGender = '"&no&"' WHERE userID = "&Request.Cookies("Database")("userID")&""


if showorientation.checked = true then

SQLQuery = "UPDATE users SET showOrientation = '"&yes&"' WHERE userID = "&Request.Cookies("Database")("userID")&""

else do

SQLQuery = "UPDATE users SET showOrientation = '"&no&"' WHERE userID = "&Request.Cookies("Database")("userID")&""

End if
%>

<%
'*** Skapa ett recordset baserat på SQL-frågan
Set rsUser = objConnection.Execute(SQLQuery)
Set rsUser = Nothing

objConnection.Close
Set objConnection = Nothing
response.redirect("profile.asp")
%>


This post has been edited by Dark_Light: 7 May, 2008 - 09:27 AM
User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 7/20/08 02:35PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month
-->