Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: Use checkboxes to access a database


Message #1 by "Gary Schells" <gschells@d...> on Tue, 15 May 2001 17:36:08
Hello,

Can anyone point me to some code or lend help in using checkboxes in a html page to open a 

database and retrieve record information per user requests?  I have checkboxes for a user to 

select topics.  These are then used to search the database and produce a table of correct 

records.  I have done this successfully with menu lists, but it appears checkboxes act 

differently than a menu list.

Thank you,

Gary
Message #2 by "Cole, R. MR DOIM" <8r8251@e...> on Tue, 15 May 2001 15:01:11 -0400
Check boxes only pass a value of 1 to an ASP page if they are checked.

Otherwise they don't even show up.



Rich Cole

Signal Corporation



-----Original Message-----

From: Gary Schells [mailto:gschells@d...]

Sent: Tuesday, May 15, 2001 1:36 PM

To: ASP Database Setup

Subject: [asp_database_setup] Use checkboxes to access a database





Hello,

Can anyone point me to some code or lend help in using checkboxes in a html

page to open a 

database and retrieve record information per user requests?  I have

checkboxes for a user to 

select topics.  These are then used to search the database and produce a

table of correct 

records.  I have done this successfully with menu lists, but it appears

checkboxes act 

differently than a menu list.

Thank you,

Gary



Message #3 by "Ken Schaefer" <ken@a...> on Wed, 16 May 2001 17:46:57 +1000
Not true:



<input type="checkbox" name="chk1" value="HaHaHa">



will pass the value HaHaHa if checked.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





: Check boxes only pass a value of 1 to an ASP page if they are checked.

: Otherwise they don't even show up.

: 

: Rich Cole

: Signal Corporation





Message #4 by "Mike Goldman" <mg188@h...> on Tue, 15 May 2001 20:39:39 -0700
How about (in the form page):



<input type=checkbox name="choice" value="A">

<input type=checkbox name="choice" value="B">



Then in your asp page:



If request.form("choice")="A" then

... do some sql to retrieve records based on choice A...

else if

request.form("choice")="B" then

... sql to retrieve records based on choice B...

end if

end if



hth





----- Original Message -----

From: Gary Schells <gschells@d...>

To: ASP Database Setup <asp_database_setup@p...>

Sent: Tuesday, May 15, 2001 5:36 PM

Subject: [asp_database_setup] Use checkboxes to access a database





> Hello,

> Can anyone point me to some code or lend help in using checkboxes in a

html page to open a

> database and retrieve record information per user requests?  I have

checkboxes for a user to

> select topics.  These are then used to search the database and produce a

table of correct

> records.  I have done this successfully with menu lists, but it appears

checkboxes act

> differently than a menu list.

> Thank you,

> Gary

> ---

> STAY UP TO DATE ON ASP.NET, C#, VB.NET, SQL and XML

> Developersdex indexes over 100 of the top ASP, SQL, VB

> and XML sites bringing in more than 5,000 new resources

> every day.  They even integrate all the top .NET

> newsgroups so you can search/post/reply across

> multiple newsgroups within their site.  The next time

> you want to find an answer on ASP, C#, SQL, VB or XML

> think of Devdex!  http://www.developersdex.com/




$subst('Email.Unsub')

>



Message #5 by "Cole, R. MR DOIM" <8r8251@e...> on Wed, 16 May 2001 08:28:26 -0400
I agree but the issue is what happens when it isn't checked.  For example, I

add a check box to a page  <input type="checkbox" name="Check"

value="ON">Check here. Then post the page, the value of checkbox doesn't

even appear because I did not check it.  IF I check the box then a value of

ON is sent or whatever value you decide.  In my case I always use 1 to show

an "ON" checked check box.  The problem that arises here is that if you have

a page of check boxes with unknown initial values sent from a recordset

there must be someway to determine their intitial state.   Looping through

the form object will only show values of checked check boxes when the page

is posted.  One solution is to provide hidden text boxes on the same page

that contain the value of the initial state of the check box as determined

by the recordset values.  When you post the page, the value combinations are

as follows:



'Check Box Status Code

'Initial Status    				 	   Final Status

Result

'   	ON						ON

1, 1

'	OFF						OFF

0, Null

'The two below is what we care about.

'	ON						OFF

1, Null

'	OFF						ON

0, 0



Again this assumes the value of the check box is set to checked when the

recordset value in this case is "Y".  For example,  



<%If rs.Fields("actv_flg").Value = "Y" then%>

	<input type="checkbox" name="<%=rs.Fields("SSN").Value%>" value="1"

checked>

	<input type="hidden" name="<%=rs.Fields("SSN").Value%>" value="1">

<%Else%>

	<input type="checkbox" name="<%=rs.Fields("SSN").Value%>" value="0">

	<input type="hidden" name="<%=rs.Fields("SSN").Value%>" value="0">

<%End if%>



Hope this explains it better.  If anyone has a better way, I'd be interested

in it.



Cheers

Rich Cole

Signal Corporation



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, May 16, 2001 3:47 AM

To: ASP Database Setup

Subject: [asp_database_setup] RE: Use checkboxes to access a database





Not true:



<input type="checkbox" name="chk1" value="HaHaHa">



will pass the value HaHaHa if checked.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





: Check boxes only pass a value of 1 to an ASP page if they are checked.

: Otherwise they don't even show up.

: 

: Rich Cole

: Signal Corporation


  Return to Index