navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

CheckBox Problem

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> CheckBox Problem
Page: [1]
 
wizard_oz

 

Posts: 140
Joined: 9/3/2004
From: Ga,USA
Status: offline

 
CheckBox Problem - 3/19/2006 9:51:45   
Hi I have a code that I can mark which software I have at my user's computer
<%
set rs2=server.CreateObject("ADODB.recordset")
sql2="select * from Software"
rs2.Open sql2,conn
while not rs2.EOF
%>
<tr>
<td><input type="checkbox" name="<%=rs2("Software")%>"></td>
<td><%=rs2("Software")%></td>
</tr>
<%
rs2.MoveNext
wend
%>
I would like to know how do I get the result of the checkbox at my other page?
Thanks, Elen
dpf

 

Posts: 7126
Joined: 11/12/2003
From: India-napolis
Status: offline

 
RE: CheckBox Problem - 3/19/2006 10:13:50   
the code should be placed inside a form with method="post" and action="yourotherpagename.asp"
where you can retreive the value with request.form

_____________________________

Dan

(in reply to wizard_oz)
wizard_oz

 

Posts: 140
Joined: 9/3/2004
From: Ga,USA
Status: offline

 
RE: CheckBox Problem - 3/19/2006 10:37:48   
Sorry I don't understand what you saying, that's all the code I am using

(in reply to dpf)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: CheckBox Problem - 3/19/2006 13:06:05   
Elen, can you post the full code for this page? It may give us a better idea of what you are doing.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to wizard_oz)
wizard_oz

 

Posts: 140
Joined: 9/3/2004
From: Ga,USA
Status: offline

 
RE: CheckBox Problem - 3/20/2006 5:46:20   
here is my code
<body>
<form action="IntoDB.asp" method="POST" id="form1" name="form1">
<table WIDTH="500" ALIGN="center" BORDER="1" CELLSPACING="1" CELLPADDING="1">
<tr><td>
<table WIDTH="300" ALIGN="center" BORDER="1" CELLSPACING="1" CELLPADDING="1">
  <tr>
    <td></td>
    <td></td></tr>
	<tr>
		<td>Computer Number</td>
		<td><input name="ComputerNumber" id="ComputerNumber"></td>
	</tr>
	<tr>
		<td>Computer Name</td>
		<td><input name="ComputerName" id="ComputerName"></td>
	</tr>
  <tr>
    <td>Name</td>
    <td><input name="fname" id="fname"></td></tr>
	<tr>
		<td>Department</td>
<%
	dim conn
	set conn=server.CreateObject("ADODB.connection")
	conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\WebSite\DataBase\TFInventory.mdb"
	set rs=server.CreateObject("ADODB.recordset")
	sql="select * from Department"
	rs.Open sql,conn

	Response.Write "<TD><SELECT name=SelDep id=SelDep> "
	while not rs.EOF
%>
			<option value="<%=rs("department")%>"><%=rs("department")%> </option>
<%
	rs.MoveNext
	wend
	rs.Close
	set rs=nothing
%>
		</select></td>
	</tr>
	<tr>
		<td>Hard-Disk</td>
		<td><input name="hd" id="hd"></td>
	</tr>
	<tr>
		<td>CPU</td>
		<td><input name="cpu" id="cpu"></td>
	</tr>
	<tr>
		<td>MEMORY</td>
<%
	set rs1=server.CreateObject("ADODB.recordset")
	sql1="select * from Memory"
	rs1.Open sql1,conn
	Response.Write "<TD><SELECT name=memory id=memory>"
	while not rs1.EOF
%>
		<option value="<%=rs1("Memory")%>"><%=rs1("Memory")%> </option>
<%
	rs1.MoveNext
	wend
	rs1.Close
	set rs1=nothing
	
%>		
		</select></td>
	
	</tr>
	<tr>
		<td>MODEL</td>
		<td><input name="model" id="model"></td>
	</tr>
  <tr>
    <td></td>
    <td></td></tr>
	<tr>
		<td>Parchase Date</td>
		<td>
		<table WIDTH="75%" BORDER="1" CELLSPACING="1" CELLPADDING="1">
	<tr>
		<td>
		<select id="SelDay" name="SelDay">
<%
	for i=1 to 31
%>
		<option><%=i%></option>
	<%next%>
	</select>
		</td>
		<td>/</td>
		<td>
		<select id="SelMonth" name="SelMonth">
<%
	for i=1 to 12
%>
		<option><%=i%></option>
	<%next%>
	</select>
		</td>
		<td>/</td>
		<td>
		<select id="SelYear" name="SelYear">
<%
	for i=2005 to 2010
%>
		<option><%=i%></option>
	<%next%>
	</select>
		</td>
	</tr>
</table>

	</tr>
	<tr>
		<td>Price</td>
		<td><input name="price" id="price"></td>
	</tr>
	<tr>
		<td>Include Windows</td>
		<td><input type="checkbox" name="IWin" id="IWin"></td>
	</tr>
	<tr>
		<td>Include Office</td>
		<td><input type="checkbox" name="IOffice" id="IOffice"></td>
	</tr>
	<tr>
		<td>Part Number</td>
		<td><input name="PartNumber" id="PartNumber"></td>
	</tr>
	<tr>
		<td></td>
		<td></td>
	</tr>
</table></td><td>
<!-- Here is the software's details -->
<table WIDTH="200" BORDER="1" CELLSPACING="1" CELLPADDING="1">
<%
	set rs2=server.CreateObject("ADODB.recordset")
	sql2="select * from Software"
	rs2.Open sql2,conn
	i=0
	while not rs2.EOF
%>
	<tr>
		<td><input type="checkbox" name="<%=rs2("Software")%>"></td>
		<td><%=rs2("Software")%></td>
	</tr>
<%
	rs2.MoveNext
	i=i+1
	wend
	Response.Write "</TABLE></td></table>"

	rs2.Close
	set rs2=nothing
	conn.Close
	set conn=nothing
%>
<input type="submit" value="Submit" id="submit1" name="submit1">
</form>

</body>

(in reply to BeTheBall)
Tarwn

 

Posts: 15
Joined: 1/19/2003
From: South-Eastern NC, USA
Status: offline

 
RE: CheckBox Problem - 3/20/2006 10:06:55   
Rather than use the name of the software as the name of your checkbox you should consider using it as the value (or vbetter, if you have an ID for the software that might work better) and specifying a hardcoded name (like checkSoftware or something else obvious like that). Forms only pass values for checkboxes when the checkboxes are passed, so on your next page you will get a comma-delimited list of the values that were checked.

Example Form:
<form method="POST" action="somepage.asp">
   <input type="checkbox" name="chkSoftware" value="MS Office" /> MS Office<br/>
   <input type="checkbox" name="chkSoftware" value="Photoshop" /> Photoshop<br/>
   <input type="checkbox" name="chkSoftware" value="Firefox" /> Firefox<br/>
   <input type="submit" value="Submit" />
</form>


Example Handler Page (somepage.asp):
<%
Option Explicit

If Len(Request.Form("chkSoftware")) = 0 Then
   Response.Write "You haven't selected any software, that makes me sad :("
Else
   Response.Write "You have selected the following software: <br />"
   Dim t_soft
   For each t_soft in Request.Form("chkSoftware")
      Response.Write t_soft & "<br />"
   Next
End If
%>


Hope this helps,
-T

--- Edited: sorry forgot the submit button in the first form

< Message edited by Tarwn -- 3/20/2006 13:22:33 >

(in reply to wizard_oz)
wizard_oz

 

Posts: 140
Joined: 9/3/2004
From: Ga,USA
Status: offline

 
RE: CheckBox Problem - 3/20/2006 12:37:18   
This example doesn't help me because I'm inserting the software from a database ( I have to do it like that)

(in reply to Tarwn)
Tarwn

 

Posts: 15
Joined: 1/19/2003
From: South-Eastern NC, USA
Status: offline

 
RE: CheckBox Problem - 3/20/2006 13:21:06   
*sigh*

The example was supposed to be a representation of what I was talking about. It is actually quite easy to take that code and turn it into a piece of database driven code.

For instance, say I have a table called "Software" that has a field named "SoftwareName":
<%
Option Explicit

Dim rs_software, obj_conn
Set obj_conn = Server.CreateObject("ADODB.Connection")
obj_conn.Open "My connection string"
%>
<html>
<body>
<form method="POST" action="wherever.asp">
Check a box:<br/>
<%
Set rs_software = obj_conn.Execute("SELECT SoftwareName FROM Software ORDER BY SoftwareName")
If Not rs_software.EOF Then rs_software.MoveFirst
Do Until rs_software.EOF
   Response.Write "<input type=""checkbox"" name=""chkSoftware"" value=""" & rs_software("SoftwareName") & """ />" & rs_software("SoftwareName") & "<br />"
   Response.Write vbCrLf  'not necessary but makes the html source prettier when debugging
   rs_software.MoveNext
Loop
set rs_software = Nothing
obj_conn.Close
Set obj_conn = Nothing
%>
<input type="submit" value="Submit" />
</form>
</body>
</html>


Tada.

(in reply to wizard_oz)
wizard_oz

 

Posts: 140
Joined: 9/3/2004
From: Ga,USA
Status: offline

 
RE: CheckBox Problem - 3/21/2006 11:50:31   
Thank you very very much
IT IS W O R K I N G .......

Elen

(in reply to Tarwn)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> CheckBox Problem
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts