Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use a checkbox in ASP

Status
Not open for further replies.

Ty1

Programmer
Dec 5, 2006
9
US
I am attempting to see if a user has selected a checkbox and if they did, update two database tables and gray out the checkbox so that it remained checked and cannot be changed on another screen. Here is my code so far:
'Declare variable
dim nsfCheck

'Initialize variable
nsfCheck = False

'=======================
' nsfCheck Flag Function
'=======================
Function nsfCheckFlagChecked(nsfCheck)
'Added by Ty Johnson 12/14/06 to see if nsf check flag checkbox checked

If (nsfCheck = True) Then
nsfCheckFlagChecked = True
Else
nsfCheckFlagChecked = False
End If
End Function

If (nsfCheck = true) Then
If application("ODBC_Oracle") Then
strSQL = strSQL & "UPDATE BadCheckReconciliation (FirstNoticeDate, NSFcheckFlag), " & vbcrlf
strSQL = strSQL & " (SET BadCheckReconciliation_seq.nextval, SQLDate( FeeTransdt ),nsfCheck) " & vbcr
strSQL = strSQL & "UPDATE Journal ( BadCheckReconciliationIdnt) " & vbcrlf
strSQL = strSQL & " FROM BadCheckReconciliation" & vbcrlf
else 'SQL 7.0
strSQL = strSQL & "UPDATE BadCheckReconciliation BCR" & vbcrlf
strSQL = strSQL & "SET FirstNoticeDate = FeeTransdt,NSFcheckFlag = nsfCheck" & vbcrlf
strSQL = strSQL & "UPDATE Journal J" & vbcrlf
strSQL = strSQL & "SET J.BadCheckReconciliationIdnt = BCR.BadCheckReconciliationIdnt" & vbcrlf
StrSQL = strSQL & " FROM BadCheckReconciliation BCR" & vbcrlf

End If
End If
 
Ty1,

Drop this code in a asp page named 1test.asp and run it

Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
	Response.Write Request.Form("cb1")
%>
<form method="post" action="1test.asp">
<INPUT type=checkbox name="cb1" >
<INPUT type=submit value=Button>

</form>
</BODY>
</HTML>



You'll note that if the checkbox is checked it will return an "on" if not checked it will return nothing.
(Response.Write Request.Form("cb1")
)

So if cb1 is on then do somthing if not do somthing else.

If request.form cb1="on" then
do somthine
else
do somthing else
end if


since the page has a form tag "<form>" the check box values is passed as a request.form item

Hope this helps
 
not seeing where you're trying to satisfy checkboxes..perhaps if using on same page then use the function you posted and add a variable called...let's say isDisabled = " disabled" OR isDisabled = ""
...and place the variable in the checkbox attributes

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top