473,509 Members | 7,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox Problem

Hi all,

I have the following code to use checkboxes on my page:
if instr(Request.form("chkWorkType"),"03") then
response.write("<td width=""23%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""03""
checked=""check"">Exterior</td>")
else
response.write("<td width=""23%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""03"">Exterior</td>")
end if

if instr(Request.form("chkWorkType"),"7A") then
response.write("<td width=""25%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""7A""
checked=""check"">Ceilings</td>")
else
response.write("<td width=""25%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""7A"">Ceilings</td>")
end if

There are 14 checkboxes on the form, I only showed the code for two, but
the remainder of them are coded the same way.

I am trying have one or more of the boxes checked when the page is
displayed. I tried to put a value or two in the chkWorkType field:

chkWorkType= oRS.fields("shty1") & oRS.fields("shty2") &
oRS.fields("shty3")

But when I reach the code to display the checkboxes, the chkWorkField
returns an empty string.

How can I pre-check some of the boxes?

Thanks,

George

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
7 1421
In article <41**********************@news.newsgroups.ws>,
an*******@devdex.com enlightened us with...
type=""checkbox"" name=""chkWorkType"" value=""7A""
checked=""check"">Ceilings</td>")
else

But when I reach the code to display the checkboxes, the chkWorkField
returns an empty string.


check should equal "true", not "check". Or just say checked.
i.e.

type=""checkbox"" name=""chkWorkType"" value=""7A""
checked=""true"">Ceilings</td>")

or
type=""checkbox"" name=""chkWorkType"" value=""7A"" checked>Ceilings</td>")
HTH

--
--
~kaeli~
Cthulhu saves our souls and redeems them for valuable
coupons later.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
On Wed, 27 Oct 2004 16:30:16 -0500, kaeli <ti******@NOSPAM.comcast.net>
wrote:

[snip]
check[ed] should equal "true", not "check". Or just say checked.
i.e.


Actually, boolean attributes like checked and selected should have
themselves as a value, or no value at all. That is:

... checked="checked"> or ... checked>

though the latter is preferred[1] as some browsers might not expect a
value.

See late in section 3.3.4 - Attribute declarations, Boolean attributes
(<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.4.2>). The
warning at the end is repeated in Appendix B, sub-section 3.4 - Boolean
attributes (<URL:http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.4>).

[snip]

Mike
[1] Except, I believe, in XHTML where a value is required.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
http://www.aspfaq.com/5003

"George" <an*******@devdex.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
Hi all,

I have the following code to use checkboxes on my page:
if instr(Request.form("chkWorkType"),"03") then
response.write("<td width=""23%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""03""
checked=""check"">Exterior</td>")
else
response.write("<td width=""23%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""03"">Exterior</td>")
end if

if instr(Request.form("chkWorkType"),"7A") then
response.write("<td width=""25%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""7A""
checked=""check"">Ceilings</td>")
else
response.write("<td width=""25%"" class=""detaillp""><input
type=""checkbox"" name=""chkWorkType"" value=""7A"">Ceilings</td>")
end if

There are 14 checkboxes on the form, I only showed the code for two, but
the remainder of them are coded the same way.

I am trying have one or more of the boxes checked when the page is
displayed. I tried to put a value or two in the chkWorkType field:

chkWorkType= oRS.fields("shty1") & oRS.fields("shty2") &
oRS.fields("shty3")

But when I reach the code to display the checkboxes, the chkWorkField
returns an empty string.

How can I pre-check some of the boxes?

Thanks,

George

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 23 '05 #4
kaeli wrote:
check should equal "true", not "check". Or just say checked.
i.e.

type=""checkbox"" name=""chkWorkType"" value=""7A""
checked=""true"">Ceilings</td>")
OT but doesn't this DTD entry: <url:
http://www.w3.org/TR/REC-html40/sgml/dtd.html />

<!ATTLIST INPUT
%attrs; -- %coreattrs, %i18n, %events --
type %InputType; TEXT -- what kind of widget is needed --
name CDATA #IMPLIED -- submit as part of form --
value CDATA #IMPLIED -- Specify for radio buttons and
checkboxes --
checked (checked) #IMPLIED -- for radio buttons and check boxes --
disabled (disabled) #IMPLIED -- unavailable in this context --
readonly (readonly) #IMPLIED -- for text and passwd --
size CDATA #IMPLIED -- specific to each type of field --
maxlength NUMBER #IMPLIED -- max chars for text fields --
src %URI; #IMPLIED -- for fields with images --
alt CDATA #IMPLIED -- short description --
usemap %URI; #IMPLIED -- use client-side image map --
ismap (ismap) #IMPLIED -- use server-side image map --
tabindex NUMBER #IMPLIED -- position in tabbing order --
accesskey %Character; #IMPLIED -- accessibility key character --
onfocus %Script; #IMPLIED -- the element got the focus --
onblur %Script; #IMPLIED -- the element lost the focus --
onselect %Script; #IMPLIED -- some text was selected --
onchange %Script; #IMPLIED -- the element value was changed --
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --

%reserved; -- reserved for possible future use --


Indicate that the only valid value for checked is "checked"? Just as the only
valid value for disabled is "disabled" and readonly is "readonly" etc?

ie-

<input type="checkbox"
...
readonly="readonly"
disabled="disabled"
checked="checked">

or

<td nowrap="nowrap" class="nr">
<!-- deprecated, but necessary since NS4 doesn't support
td.nr { white-space: nowrap; } -->

Or am I reading the specification wrong?

Anyway, that's the way I was taught and the way I do it. For attributes that
have no "value", I supply a quoted value equal to the attribute name (I'm
trying to think of any cases where I do not do this, there may be some but not
many).

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #5
In article <41***************@agricoreunited.com>, gw*****@agricoreunited.com
enlightened us with...

Anyway, that's the way I was taught and the way I do it. For attributes that
have no "value", I supply a quoted value equal to the attribute name (I'm
trying to think of any cases where I do not do this, there may be some but not
many).


Sorry, yeah, I stand corrected.
I always just use "checked" standalone, myself.
IIRC, if you get the value of a checkbox from a form, isn't it "true" if it's
checked? I think that's what I was thinking of.

OP needs to fix 'checked="check"' to 'checked="checked"'.

--
--
~kaeli~
Shotgun wedding: A case of wife or death.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #6
On Thu, 28 Oct 2004 13:16:20 -0500, kaeli <ti******@NOSPAM.comcast.net>
wrote:

[snip]
IIRC, if you get the value of a checkbox from a form, isn't it "true" if
it's checked? [...]
It's value is exactly the same as every other form control: the content of
the value attribute. The checked state of a checkbox only determines
whether the control is successful, and therefore whether its value is
submitted along with the rest of the form data.

If checkbox is unchecked, it still has the value specified in the value
attribute, but it won't be sent to the server.
OP needs to fix 'checked="check"' to 'checked="checked"'.


Or just 'checked'.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7
In article <opsglfdebkx13kvk@atlantis>, M.******@blueyonder.co.invalid
enlightened us with...
IIRC, if you get the value of a checkbox from a form, isn't it "true" if
it's checked? [...]


It's value is exactly the same as every other form control: the content of
the value attribute. The checked state of a checkbox only determines
whether the control is successful, and therefore whether its value is
submitted along with the rest of the form data.

If checkbox is unchecked, it still has the value specified in the value
attribute, but it won't be sent to the server.


Ah, okay, thanks.

--
--
~kaeli~
Support your local medical examiner: die strangely!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6014
by: Claire | last post by:
Hello, I am having a problem in my struts application with the checkboxes in my form. I have an array of checkboxes, some of which may be already selected when the form loads. My problem is when...
2
2309
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their...
0
2389
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
10
2402
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
4
3927
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
1
4011
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works...
9
1785
by: morellik | last post by:
Dear all, I have a program that creates dinamically a web page. In the page I have the following function to check how many checkbox are checked. function tarInfo(info) { var i=0; var c=0;...
0
4078
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
3
2892
by: Mahathi | last post by:
Hi I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that. My requirement is that "I have to map some roles with...
4
4428
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.