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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox and database 1

Status
Not open for further replies.

PhatH

IS-IT--Management
Mar 30, 2004
88
US
Hi all

I have a checkbox and input will save into database in BIT (0, 1)

This is a code i use to retrieve data from database:
<input type="checkbox" name="pnew" value="<% =pnew %>" <% if (pnew) then response.write ("Checked") %>>NEW?

This is what I've been think of:
If pnew = True Then
pnew = 1
Else
pnew = 0
End If

What I want is to convert to 1 if CHECKED and 0 if UNCHECKED. So far, either nothing changes or ERROR:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'False'.

Could someone tell me how to make it works?
 
what i've done in the past is to write a small funtion where I pass 2 variable is and the output if check or unchecked.

Code:
function check_values(obj_id, pull_id)
' do a number match here for the drop down menus
	if Cint(obj_id)= Cint(pull_id) then
		output = "Checked"
	else
		output = ""
	end if
	check_values = output

end function

this would then be implemented as
Code:
<%= check_values(obj_id, pull_id)%>

this works for drop down boxes too. instead of checked you use Selected

but there may be a better way of doing this
 
what i've done in the past is to write a small funtion where I pass 2 variable is and the output if check or unchecked.

Code:
function check_values(obj_id, pull_id)
' do a number match here 
	if Cint(obj_id)= Cint(pull_id) then
		output = "Checked"
	else
		output = ""
	end if
	check_values = output

end function

this would then be implemented as
Code:
<%= check_values(obj_id, pull_id)%>

this works for drop down boxes too. instead of checked you use Selected

but there may be a better way of doing this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top