| | |
how do i get more than one checkbox being checked
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
what's wrong with my code? how come only 1 checkbox is checked when there should be 2 checked checkboxes?
THANKS.
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.
ASP Syntax (Toggle Plain Text)
<% 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 %>
THANKS.
cheers,
ohgosh
ohgosh
•
•
Join Date: May 2005
Posts: 514
Reputation:
Solved Threads: 19
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 ?
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 ?
•
•
Join Date: May 2005
Posts: 514
Reputation:
Solved Threads: 19
•
•
•
•
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.
what's wrong with my code? how come only 1 checkbox is checked when there should be 2 checked checkboxes?ASP Syntax (Toggle Plain Text)
<% 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 %>
THANKS.
varcount=0
inside the loop do
varcount= varcount+1
namevar=deleted+varcount
<td><input name="& namevar &" blah blabvh
You follow?
do u mean this:
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,
it gave me this:
Admin Admin
Admin Student
Admin Parent
Admin Teacher
Admin Principal
how and what should i do?
ASP Syntax (Toggle Plain Text)
<% 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 %>
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,
ASP Syntax (Toggle Plain Text)
<%response.Write(rsView("userType") & rsUser("userType"))%>
Admin Admin
Admin Student
Admin Parent
Admin Teacher
Admin Principal
how and what should i do?
cheers,
ohgosh
ohgosh
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?
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?
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
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
ASP Syntax (Toggle Plain Text)
<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
ohgosh
![]() |
Similar Threads
- MySQL Checkbox Multiple data Delete? (PHP)
- PHP Checkbox (PHP)
- asp:repeater in a form? (ASP.NET)
- get checkbox value (PHP)
- Help! Mail inbox is locked - how can I unlock it? (Mac Software)
- checkbox values calculation with PHP (PHP)
- grouping unique name in table (MS SQL)
- a weird Javascript error (JavaScript / DHTML / AJAX)
Other Threads in the ASP Forum
- Previous Thread: how do i get the current time when i click a button?
- Next Thread: help need for dropdownlist
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection diagnostics dreamweaver excel fso iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit webserver windows7





