User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,593 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,665 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 6157 | Replies: 6
Reply
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

how do i get more than one checkbox being checked

  #1  
Aug 22nd, 2005
HI there,

i haf a series of dynamic checkbox retrieved from db. I can display my checkbox successfully but now i cant get more than one checkbox being checked.

<%
     sqlUser= "select distinct * from t_user_type order by userType"
     set rsUser = conn.execute(sqlUser)
		
     do while not rsUser.eof
		
     sqlView = "select * from t_email_view where emailID = '" & emailID & "' and emailView = '1' order by userType"
     set rsView = conn.execute(sqlView)
%>

<tr>
     <td><input name="deleted" type="checkbox" value="<%=rsUser("userType")%>" <%if rsView("userType")=rsUser("userType") then response.Write(" checked")%> ><%=rsUser("userDesc")%></td>
</tr>
<%
     rsUser.moveNext
     loop
%> 
what's wrong with my code? how come only 1 checkbox is checked when there should be 2 checked checkboxes?

THANKS.
cheers,
ohgosh
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 494
Reputation: techniner is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 18
techniner techniner is offline Offline
Posting Pro in Training

Re: how do i get more than one checkbox being checked

  #2  
Aug 23rd, 2005
The problem is they have the same NAME

Your telling it

<input name="deleted" <--- So it loops through

So you need to dynamically rename these boxes.

maybe increment the variable like +1 and walk the loop giving each input a different name ?
Did my post help?
Visit Little Jon's Web Portal


Generate Traffic with Maximum Traffic Software
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: how do i get more than one checkbox being checked

  #3  
Aug 23rd, 2005
so how should i do? any improvement on d code u could provide in here? sorry to bother u..

So you need to dynamically rename these boxes.

what do u mean? could u explain furthermore? thanks~
cheers,
ohgosh
Reply With Quote  
Join Date: May 2005
Posts: 494
Reputation: techniner is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 18
techniner techniner is offline Offline
Posting Pro in Training

Re: how do i get more than one checkbox being checked

  #4  
Aug 23rd, 2005
Originally Posted by ohgosh
HI there,

i haf a series of dynamic checkbox retrieved from db. I can display my checkbox successfully but now i cant get more than one checkbox being checked.

<%
     sqlUser= "select distinct * from t_user_type order by userType"
     set rsUser = conn.execute(sqlUser)
		
     do while not rsUser.eof
		
     sqlView = "select * from t_email_view where emailID = '" & emailID & "' and emailView = '1' order by userType"
     set rsView = conn.execute(sqlView)
%>

<tr>
     <td><input name="deleted" type="checkbox" value="<%=rsUser("userType")%>" <%if rsView("userType")=rsUser("userType") then response.Write(" checked")%> ><%=rsUser("userDesc")%></td>
</tr>
<%
     rsUser.moveNext
     loop
%> 
what's wrong with my code? how come only 1 checkbox is checked when there should be 2 checked checkboxes?
THANKS.

Well Do something like this

varcount=0

inside the loop do
varcount= varcount+1
namevar=deleted+varcount


<td><input name="& namevar &" blah blabvh

You follow?
Did my post help?
Visit Little Jon's Web Portal


Generate Traffic with Maximum Traffic Software
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: how do i get more than one checkbox being checked

  #5  
Aug 23rd, 2005
do u mean this:

<%
     i = 0
     varcount = 0
     sqlUser= "select * from t_user_type order by userType"
     set rsUser = conn.execute(sqlUser)
		
     do while not rsUser.eof
     i = i + 1
     varcount = varcount + 1
     deleted = deleted + varcount
	
     sqlView = "select * from t_email_view where emailID = '" & emailID & "' and emailView = '1' order by userType"
     set rsView = conn.execute(sqlView)
%>

<tr>
     <td><input name="deleted" type="checkbox" value="<%=rsUser("userType")%>" <%if rsView("userType")=rsUser("userType") then response.Write(" checked")%> ><%=rsUser("userDesc")%></td>
</tr>
<%
     rsUser.moveNext
     loop
%>

nothing happens, it is still the same..

i think something's wrong with my checking of checked checkboxes statement. it doesn't seem to loop thru the rsView("userType").

when i do a response.write in the <td> tag,

<%response.Write(rsView("userType") & rsUser("userType"))%>
it gave me this:

Admin Admin
Admin Student
Admin Parent
Admin Teacher
Admin Principal

how and what should i do?
cheers,
ohgosh
Reply With Quote  
Join Date: Mar 2005
Location: LTT, South Africa
Posts: 125
Reputation: william_stam is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
william_stam's Avatar
william_stam william_stam is offline Offline
Junior Poster

Re: how do i get more than one checkbox being checked

  #6  
Aug 24th, 2005
im seriously not following. where does the checkboxes come into it?


what do you hope to achieve???


you might want to change the name of the checkbox

if you pass it like that it would come out as ?deleted=1,2,3,4,5. which unless you right a split routine it wont help you.

<tr>
<td><input name="<%=deleted%>" type="checkbox" value="<%=rsUser("userType")%>" <%if rsView("userType")=rsUser("userType") then response.Write(" checked")%> ><%=rsUser("userDesc")%></td>
</tr>


surely there should be an endif there?
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: how do i get more than one checkbox being checked

  #7  
Aug 29th, 2005
heiya.. thanks william_stam!! saw so many of your replies & am grateful.. seems that you're quite pro in programmin ar?

anyw.. i use diff way to store my checkbox n the checking of the checkboxes by hard coding them and not retrieving frm db anymore.. i still have a Qn.. how do i validate them? validate to check that one of the checkbox must be checked in order to save the changes in the current page.

here are my checkbox codings
<input type="checkbox" name="stud" value="yes">Student
<input type="checkbox" name="lect" value="yes">Lecturer
<input type="checkbox" name="principal" value="yes">Principal 
<input type="checkbox" name="admin" value="yes">Administrator 
<input type="checkbox" name="parent" value="yes">Parent
cheers,
ohgosh
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 11:29 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC