Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2006, 11:50 PM
Registered User
 
Join Date: Dec 2006
Location: Columbus, Ohio, .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEWBIE - Interact with checkbox

I have tried to read from my checkbox using request.form, but I don't believe I have done it right. Also, do I need to set my checkbox value to false or 0 when updating SQL server?

'declare variable
dim nsfCheck

'Initialize variable
nsfCheck = False

'=======================
' nsfCheck Flag Function
'=======================
Function nsfCheckFlagChecked(nsfCheck)


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

<INPUT TYPE=CHECKBOX NAME=nsfCheck VALUE=False><BR>

Ty
 
Old December 19th, 2006, 12:18 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;but I don't believe I have done it right
tricky to tell without seeing your checkbox and the way you are looking at it. If you checkbox is called 'someName' then you look at the value by <%= request.form("someName") %> providing you have used method="post" inside your form tag otherwise use <%= request.querystring("someName") %>

;;;Also, do I need to set my checkbox value to false or 0 when updating SQL server?
if the field is required and its a true false field yes. I tend to make a true false field have a default value. EG I have a field called 'inactive' I make it true/false data type and set a default insert value of 0 (false) - this way you only need to address it if you are inactivting a record. IMO using default values is a very good practice

Wind is your friend
Matt
 
Old December 19th, 2006, 08:09 AM
Registered User
 
Join Date: Dec 2006
Location: Columbus, Ohio, .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my checkbox:

dim nsfCheck
nsfCheck = "0"

<td><input type="checkbox" name="nsfCheck" value="0"></td>
Function nsfCheckFlagChecked(nsfCheckBox)

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




Ty
 
Old December 19th, 2006, 05:12 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;I have tried to read from my checkbox using request.form, but I don't believe I have done it right.

You did not post the problematic code in relation to this question. Read from your checkbox on the page it posts to providing you are using method=post using:
<%= trim(request.form("nsfCheck")) %>

Whay are you comparing your checkbox to? You code says:
nsfCheck = "0"
then you ask a server side function:
If (nsfCheck = True) Then
You have set nsfCheck to a string value of "0" - this is not true or false, its a string containing 0.

I have no idea what you are trying to do with the checkbox however, If you want to compare someValue against someVariable, I would:
<input type="checkbox" name="nsfCheck" value="<% if somevariable = someValue then response.write "checked" end if %>">




Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to interact with data using ADO rohit_ghosh Access 1 May 21st, 2008 09:11 AM
How to interact with Biometric devices ? indiangeeks Pro PHP 1 March 7th, 2007 06:27 AM
2 different DBs.how they can interact to one anoth saif44 ASP.NET 2.0 Basics 1 March 2nd, 2006 06:32 AM
Interact with files Snib Javascript How-To 4 November 19th, 2003 02:17 PM
Loading Images & Interact with Outlook wasaan SQL Server ASP 1 August 4th, 2003 06:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.