| Author |
Topic Search Topic Options
|
faubo
Senior Member
Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
|
Post Options
Thanks(0)
Quote Reply
Topic: Multiple Checkboxes Posted: 15 June 2003 at 3:16pm |
Hello,
This is teh first time I'm using a multiple checkbox...
I have many options, each of one witha different value.
Question:
How do I add in a DB field something like
1, 2, 4, 5
These numbers correspond to the checkboxes value.
Thanks
|
|
|
 |
Bullschmidt
Groupie
Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
|
Post Options
Thanks(0)
Quote Reply
Posted: 16 June 2003 at 12:33am |
I THINK this would work. Keep the same name for all the checkboxes but still change the values:
<input type="checkbox" name="MyCheckBoxGroup" value="1">
<input type="checkbox" name="MyCheckBoxGroup" value="2">
|
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
|
 |
faubo
Senior Member
Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 2:31pm |
Ok,
it worked.
Now I have a more complicated problem.
I have the slectbox filed in my DB like that "1, 3, 4, 5"
How to read that from the DB and make the boxes checked for an "Edit profile" page?
|
|
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 3:10pm |
|
How about
<%
strDBField = RS("DBField")
for i = 1 to 5 %>
<input type="checkbox" name="MyCheckBoxGroup" value="<%=i%>" <% if inStr(strDBField,i)>0 then Response.Write " checked" end if %>>
<% next %>
this works from 0-9 but not for 2 or more digit numbers
|
|
|
 |
faubo
Senior Member
Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 3:47pm |
I will give it a try,
I'm a little dumb dealing with multiple boxes (more than usual I mean)... not sure why...
Why this won't work with more then 9 kinds of selection? I have one with 16 options...
Thanks anyway,
and any more help I will be glad to read, I browse some asp sites and didn't find this in nowhere.
Edited by faubo
|
|
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 3:56pm |
|
It won't work with multiple digits because 1, 21, 311, etc all contain 1. When I have more than 0-9 I use the following
<%
strDBField = "|"&Replace(rs("dbfield"),", ","|")&"|"
x=50
for i = 0 to x %>
<input type="checkbox" name="MyCheckBoxGroup" value="<%=i%>" <% if inStr(strDBField,"|"&i&"|")>0 then Response.Write " checked" end if %>>
<%
next
%>
|
|
|
 |
faubo
Senior Member
Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 4:39pm |

Microsoft VBScript compilation error '800a041f'
Unexpected 'Next'
/TESTES/modelreg2.asp, line 412 next
^
|
|
|
 |
faubo
Senior Member
Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 June 2003 at 4:45pm |
Ok, my mistake, solve that next thing.
Now I'm starting to get what are you doing...
But how do you write the name (option) in the side of the box using this? I got 5 box with the of the first one.
|
|
|
 |