Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Multiple Checkboxes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Multiple Checkboxes

 Post Reply Post Reply Page  123>
Author
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Bullschmidt View Drop Down
Groupie
Groupie


Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bullschmidt Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
%>
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2003 at 4:39pm

Microsoft VBScript compilation error '800a041f'

Unexpected 'Next'

/TESTES/modelreg2.asp, line 412

next
^
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.