Another checkbox manipulation question

J

Jack

<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write
l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else
Response.Write " unchecked"%>>

The above code shows a checkbox on a asp form where the checkbox value is
stored and retrived from a field in an
Access database.

When the checkbox is unchecked, for some reason, the value of checkbox shows
null value instead of showing False
(This is the sql processing and database update asp page)

I would like to force this value to be false in the event the
(Request.Form("chk_Complete") value is null.

The following is the code to force False value in the above field. However,
the value is stil null. Any
help is appreciated. The variable output and the sql generated for unchecked
and checked cases are also shown.




if CBool(Request.Form("chk_Complete")) = "" Then
Cbool(Request.Form("chk_Complete")) = "False"
end if
l_f_IsChecked = (Request.Form("chk_Complete"))
CASE: CHECKBOX UNCHECKED

START CHECK COMPLETE

THE END
StartCheckBox

EndCheckbox

UPDATE tblGMISExpenditures_Quarter SET
tblGMISExpenditures_Quarter.CurrentOutlay= '$550.00' ,
tblGMISExpenditures_Quarter.LocalShare= '$100.50' ,
tblGMISExpenditures_Quarter.MBCCShare= '449.5' ,
tblGMISExpenditures_Quarter.UnpaidOblig= '$250.00' ,
tblGMISExpenditures_Quarter.LocalShareUnpaidOblig= '$35.35' ,
tblGMISExpenditures_Quarter.ProjectIncome= '$100.00' ,
tblGMISExpenditures_Quarter.ForfeitureIncome= '$200.00' ,
tblGMISExpenditures_Quarter.OtherExpense= '$30.00' ,
tblGMISExpenditures_Quarter.ForfeitureExpense= '$40.00' ,
tblGMISExpenditures_Quarter.InterestReceived= '$20.00' ,
tblGMISExpenditures_Quarter.TotalPeriodOutlay= '4568.39' ,
tblGMISExpenditures_Quarter.Remarks= 'Testing GWIS' ,
tblGMISExpenditures_Quarter.Name= 'Jack Jones' ,
tblGMISExpenditures_Quarter.Title= 'Manager' ,
tblGMISExpenditures_Quarter.AreaCode= '111' ,
tblGMISExpenditures_Quarter.Phone1= '111' ,
tblGMISExpenditures_Quarter.Phone2= '8762' ,
tblGMISExpenditures_Quarter.Date= '1/11/2005' ,
tblGMISExpenditures_Quarter.IsChecked= where
tblGMISExpenditures_Quarter.SubgrantIntID = 4836;

CASE: CHECK BOX CHECKED

START CHECK COMPLETE
TRUE
THE END
StartCheckBox
TRUE
EndCheckbox

UPDATE tblGMISExpenditures_Quarter SET
tblGMISExpenditures_Quarter.CurrentOutlay= '$550.00' ,
tblGMISExpenditures_Quarter.LocalShare= '$100.50' ,
tblGMISExpenditures_Quarter.MBCCShare= '449.5' ,
tblGMISExpenditures_Quarter.UnpaidOblig= '$250.00' ,
tblGMISExpenditures_Quarter.LocalShareUnpaidOblig= '$35.35' ,
tblGMISExpenditures_Quarter.ProjectIncome= '$100.00' ,
tblGMISExpenditures_Quarter.ForfeitureIncome= '$200.00' ,
tblGMISExpenditures_Quarter.OtherExpense= '$30.00' ,
tblGMISExpenditures_Quarter.ForfeitureExpense= '$40.00' ,
tblGMISExpenditures_Quarter.InterestReceived= '$20.00' ,
tblGMISExpenditures_Quarter.TotalPeriodOutlay= '4568.39' ,
tblGMISExpenditures_Quarter.Remarks= 'Testing GWIS' ,
tblGMISExpenditures_Quarter.Name= 'Jack Jones' ,
tblGMISExpenditures_Quarter.Title= 'Manager' ,
tblGMISExpenditures_Quarter.AreaCode= '111' ,
tblGMISExpenditures_Quarter.Phone1= '111' ,
tblGMISExpenditures_Quarter.Phone2= '8762' ,
tblGMISExpenditures_Quarter.Date= '1/11/2005' ,
tblGMISExpenditures_Quarter.IsChecked= TRUE where
tblGMISExpenditures_Quarter.SubgrantIntID = 4836;
 
M

Mark Schupp

When the checkbox is unchecked the value is not sent in the form.
Try something like this;

<input type="checkbox" name="chk_Complete" value="TRUE"
<%if cbool(l_IsChecked) then Response.Write " checked" %>>

and

If Trim(Request.Form("chk_Complete")) = "TRUE" Then
l_f_IsChecked = "TRUE"
Else
l_f_IsChecked = "FALSE"
End If

I'd also suggest using boolean values instead of tossing CBool in
everywhere.

<input type="checkbox" name="chk_Complete" value="TRUE"
<%if l_IsChecked then Response.Write " checked" %>>

and

If Trim(Request.Form("chk_Complete")) = "TRUE" Then
l_f_IsChecked = True
Else
l_f_IsChecked = True
End If
 
J

Jack

I got help from Bob Barrows in an earlier posting about the checkbox and it
solved the problem. Thanks anyways.
 
J

Jack

Thanks Mark for your help. I have already got it solved. However, I am going
to try it the way you suggested. Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top