Return To Home Page - Link to "The Wanker" - Contact Us


Return To Home Page

Forms - Populating a check box with info from a database



Below is an example of populating a check box for use with a Boolean (Yes/No) field in your database.

This is just an example.. when doing this for real you would do a query to determine the existing values for all the form fields... for this example we will populate the variable ourselves with either a "True" or "False" value. If the value passed to the save page is not "True" then it is "False" and therefore you update the database accordingly.

<%
FRONTPAGE_ACCESS = "True"
%>

<form method="POST" action="somepage.asp">
<div align="center"><center><table border="0">
<tr>
<td>FRONTPAGE_ACCESS</td>
<td><input type="checkbox" name="FRONTPAGE_ACCESS" value="True"
<% If FRONTPAGE_ACCESS = "True" Then Response.Write (" checked") %>></td>
</tr>
</table>
</center></div>
</form>

And this is what the output would look like if the boolean field was "True".

FRONTPAGE_ACCESS
 

Below is an example of populating a check box for use with a text field in your database where you have manually inserted text like"Yes" or "No".

This is just an example.. when doing this for real you would do a query to determine the existing values for all the form fields... for this example we will populate the variable ourselves with eithor a "Yes" or "No" value. On the save page if the field passed doesn't = "Yes" then it is the opposite so in this case you assign the database the "No" value on the save page

<%
CGI_ACCESS = "No"
%>

<form method="POST" action="somepage.asp">
<div align="center"><center><table border="0">
<tr>
<td>CGI_ACCESS</td>
<td><input type="checkbox" name="CGI_ACCESS" value="Yes"
<% If CGI_ACCESS = "Yes" Then Response.Write (" checked") %>></td>
</tr>
</table>
</center></div>
</form>

And this is what the output would look like if the text field has the text "No" in it

CGI_ACCESS

Banner
ASP (Active Server Pages) is a technology developed by Microsoft. Pages using ASP are primarily developed in JScript, or VBScript and are integrated into the HTML of your Web pages. The ASP code is compiled on-the-fly by the server and the resulting output is standard HTML. By using ASP, Web pages can be dynamic, full of ever-changing content, and browser independent.
Active Server Pages what is asp programming how to sample asp example code scripts software asp forum mail sessions applications global.asa CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com,www.abay.com

 

Link to "The Wanker"
© 2007 CodeWanker - Active Server Pages Articles, Code Snippets, & Tutorials