Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Checkboxes on forms


Message #1 by "Rod Aubertin" <webmstr@r...> on Fri, 18 Aug 2000 21:16:37
I have successfully filled in a form with values from a query, but my 

question is how would I go about showing 'checkboxes' as checked if the 

value from the query is true.



Like I said I'm fine with the text box fields, but this one has me 

stumped.

Message #2 by "Alberto Jacomuzzi" <ajacomuzzi@w...> on Mon, 21 Aug 2000 12:22:06 +0200
> I have successfully filled in a form with values from a query, but my

> question is how would I go about showing 'checkboxes' as checked if the

> value from the query is true.

>

> Like I said I'm fine with the text box fields, but this one has me

> stumped.



Hi Rod,

I think you can try this sintax.

Check out if the variable "yourname" is true or not while showing the

checkbox



<input type="checkbox" name="yourname" value="1"<%if yourname=1

then%>CHECKED<%end if%>>



Hope you'll need it



JAco



Message #3 by Imar Spaanjaars <Imar@S...> on Mon, 21 Aug 2000 12:22:45 +0200
This is rather easy, just add the word checked to your checkbox definition:



<% if something =  true then %>

         <INPUT TYPE="checkbox" ID="checkbox1" NAME="checkbox1" checked>

<% else %>

         <INPUT TYPE="checkbox" ID="checkbox1" NAME="checkbox1">

<% end if %>





Imar



P.S. Don't follow my example on context-switching (between ASP en HTML). 

Rather use Response.Write to write out the HTML.





At 09:16 PM 8/18/2000 +0000, you wrote:

>I have successfully filled in a form with values from a query, but my

>question is how would I go about showing 'checkboxes' as checked if the

>value from the query is true.

>

>Like I said I'm fine with the text box fields, but this one has me

>stumped.

>

Message #4 by Mark Everest <Mark.Everest@t...> on Mon, 21 Aug 2000 11:30:38 +0100
There is an HTML attribte that you must specify to set whether the box is

checked or not



e.g.



<input type="checkbox" checked name="mybox" />



So in your code you could do the following:







' Write the start of the html tag

response.write "<input type=""checkbox"" "



' Check the value in the database

if setRecs("value1") = true then

	' Set as checked

	response.write "checked "

end if



' Write the end of the tag

response.write "name=""mybox"" />"







I hope this helps - let me know if yo still have issues.



  

 

Mark









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

From: Rod Aubertin 

Sent: 18 August 2000 22:17

To: ASP Databases

Subject: [asp_databases] Checkboxes on forms





I have successfully filled in a form with values from a query, but my 

question is how would I go about showing 'checkboxes' as checked if the 

value from the query is true.



Like I said I'm fine with the text box fields, but this one has me 

stumped.



Message #5 by "Nick Middleweek" <nickm@t...> on Mon, 21 Aug 2000 11:51:52 +0000
Rod,



There is an attribute to the checkbox form element that tells the browser to

render it as checked.



<INPUT TYPE="checkbox" NAME="vCheck" VALUE="true" checked>



This will display a checked checkbox!





HTH



Regards

Nick Middleweek





----------

> I have successfully filled in a form with values from a query, but my

> question is how would I go about showing 'checkboxes' as checked if the

> value from the query is true.

>

> Like I said I'm fine with the text box fields, but this one has me

> stumped.

>

> ---

> You are currently subscribed to asp_databases


> 


  Return to Index