473,396 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Radio buttons do not appear checked

<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>
I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.

What can I do?

Phil
Jul 17 '05 #1
15 10773
I think what you want want is to change your input type to "checkbox"

Cheers,
Mike

"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>
I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.

What can I do?

Phil

Jul 17 '05 #2
On 30 Sep 2003 13:41:13 -0700, so*****@erols.com (Phil Powell) wrote:
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>
I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.


Works for me, on IE6 and Mozilla 1.4. What browser are you using?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
In article <1c**************************@posting.google.com >,
so*****@erols.com says...
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>

I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.
Works for me in IE6 and Firebird 0.6.1

What can I do?


Find a more appropriate group. This is neither a PHP nor JavaScript
issue.

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
Jul 17 '05 #4
On Tue, 30 Sep 2003 23:48:57 +0300, "Mike" <no*****@noemail.com> wrote:
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google. com...
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No


I think what you want want is to change your input type to "checkbox"


Why? How can the reply be 'Yes' and 'No' at the same time? Radio looks the
sensible choice here.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #5
VK
Any name has to start with a letter and consist of any combination of
letters, numbers and underscores to the total length of 255 characters.
(Where the "letter" means any character from the a-z, A-Z range)
This is a vary basic of any programming language including JavaScript.
Otherwise you are on the merci of a particular system (browser) - will it
eat your wrong names or not.

Phil Powell <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>
I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.

What can I do?

Phil

Jul 17 '05 #6
On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <sc**********@yahoo.com> wrote:
Phil Powell <so*****@erols.com> wrote in message
news:1c**************************@posting.google. com...
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>

I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.
Any name has to start with a letter and consist of any combination of
letters, numbers and underscores to the total length of 255 characters.
(Where the "letter" means any character from the a-z, A-Z range)


Not true, see below.
This is a vary basic of any programming language including JavaScript.
Otherwise you are on the merci of a particular system (browser) - will it
eat your wrong names or not.


permission[4] is a valid value for the name attribute of the <input> element,
as described in the HTML specification.

The input element's name attribute is of type CDATA with no further
restrictions defined by the specification.

The last discussion I remember of this ended up with these messages:
(very long URL - your newsreader may wrap it)

http://groups.google.co.uk/groups?hl...r%3D%26hl%3Den

The message linked says [] in an input name is invalid, the replies disprove
this.

Individual languages may have trouble with non-alphabetic characters as part
of a name attribute, but it's valid HTML and so should really be possible to
deal with it in any language working with HTML.

(BTW I'm not sure why this is posted to either of the PHP or JavaScript
newsgroups, since the only posted content is in valid HTML)

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #7
I noticed that Message-ID: <3f***********************@news.freenet.de>
from VK contained the following:
Any name has to start with a letter and consist of any combination of
letters, numbers and underscores to the total length of 255 characters.
(Where the "letter" means any character from the a-z, A-Z range)
This is a vary basic of any programming language including JavaScript.
Otherwise you are on the merci of a particular system (browser) - will it
eat your wrong names or not.


Wish I'd read that earlier. I spent three hours today trying to figure
out a simple javascript problem until I figured out I could not call my
checkboxes 1,2,3, etc

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:n6********************************@4ax.com...
On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <sc**********@yahoo.com> wrote:
<snip>
Any name has to start with a letter and consist of any
combination of letters, numbers and underscores to the
total length of 255 characters. (Where the "letter" means
any character from the a-z, A-Z range)


Not true, see below.

<snip>
The message linked says [] in an input name is invalid, the
replies disprove this.
I don't think that the discussion that you referenced does prove the
general suggestion that [ and ] are invalid in HTML 4 name attribute
strings is incorrect. If I look at the HTM versions of the DTDs I find
that the Name attributes are described as CDATA and the term CDATA is
linked to:-

<quote cite="http://www.w3.org/TR/html4/types.html#type-cdata">
....
For some HTML 4 attributes with CDATA attribute values, the
specification imposes further constraints on the set of legal values for
the attribute that may not be expressed by the DTD.
....

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").
....
</quote>

- which is part of the HTML 4 specification and "imposes further
constraints" on the contents of name attribute strings beyond the normal
definition of CDATA.
Individual languages may have trouble with non-alphabetic
characters as part of a name attribute, but it's valid HTML
and so should really be possible to deal with it in any
language working with HTML.


Valid HTML or not, JavaScript can access properties with names that do
not represent valid identifiers in JavaScript by using square bracket
notation instead of dot notation:-

<URL: http://jibbering.com/faq/#FAQ4_25 >
-and-
<URL: http://jibbering.com/faq/#FAQ4_39 >

Richard.
Jul 17 '05 #9
On Wed, 1 Oct 2003 01:35:37 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote:
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:n6********************************@4ax.com.. .
On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <sc**********@yahoo.com>wrote:
<snip>
Any name has to start with a letter and consist of any
combination of letters, numbers and underscores to the
total length of 255 characters. (Where the "letter" means
any character from the a-z, A-Z range)


Not true, see below.

<snip>

The message linked says [] in an input name is invalid, the
replies disprove this.


I don't think that the discussion that you referenced does prove the
general suggestion that [ and ] are invalid in HTML 4 name attribute
strings is incorrect. If I look at the HTM versions of the DTDs I find
that the Name attributes are described as CDATA and the term CDATA is
linked to:-

<quote cite="http://www.w3.org/TR/html4/types.html#type-cdata">
...
For some HTML 4 attributes with CDATA attribute values, the
specification imposes further constraints on the set of legal values for
the attribute that may not be expressed by the DTD.
...

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").


The name attribute of input is not one of the ID or NAME types, so that
restriction doesn't apply.

There are attributes that are declared as ID or NAME; input's name attribute
is not one of them.
...
</quote>

- which is part of the HTML 4 specification and "imposes further
constraints" on the contents of name attribute strings beyond the normal
definition of CDATA.


No, the restriction on the NAME and ID types don't apply to the CDATA type.

Quoting the whole lot:

"
* CDATA is a sequence of characters from the document character set and may
include character entities. User agents should interpret attribute values as
follows:
Replace character entities with characters,
Ignore line feeds,
Replace each carriage return or tab with a single space.
User agents may ignore leading and trailing white space in CDATA attribute
values (e.g., " myval " may be interpreted as "myval"). Authors should not
declare attribute values with leading or trailing white space.

For some HTML 4 attributes with CDATA attribute values, the specification
imposes further constraints on the set of legal values for the attribute that
may not be expressed by the DTD.

Although the STYLE and SCRIPT elements use CDATA for their data model, for
these elements, CDATA must be handled differently by user agents. Markup and
entities must be treated as raw text and passed to the application as is. The
first occurrence of the character sequence "</" (end-tag open delimiter) is
treated as terminating the end of the element's content. In valid documents,
this would be the end tag for the element.

* ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by
any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons
(":"), and periods (".").

* IDREF and IDREFS are references to ID tokens defined by other attributes.
IDREF is a single token and IDREFS is a space-separated list of tokens.

* NUMBER tokens must contain at least one digit ([0-9]).
"

So, it's saying that if you look through the specification on some of the
attributes that are of CDATA type, there are then further notes on restrictions
not expressed by it being of type CDATA.

There are no further restrictions listed for input's name attribute that I can
find - if you can see one please post it!

There then follows descriptions of the ID, NAME, IDREF, IDREFS and NUMBER
types; none of which are CDATA, they're separate types.

For example:

http://www.w3.org/TR/html4/struct/li...ml#adef-name-A

The name attribute of the <a> tag is of type CDATA, but it says here that it
is restricted to the namespace of the id attribute, which is of type 'name'.

That's a "further constraint on the set of legal values for the attribute that
may not be expressed by the DTD"
Individual languages may have trouble with non-alphabetic
characters as part of a name attribute, but it's valid HTML
and so should really be possible to deal with it in any
language working with HTML.


Valid HTML or not, JavaScript can access properties with names that do
not represent valid identifiers in JavaScript by using square bracket
notation instead of dot notation:-

<URL: http://jibbering.com/faq/#FAQ4_25 >
-and-
<URL: http://jibbering.com/faq/#FAQ4_39 >


Sounds good.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #10
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:od********************************@4ax.com...
<snip>
No, the restriction on the NAME and ID types don't apply to
the CDATA type.

<snip>

Looking at it again I think you are right. Looking at the HTML source of
types.html made it clear that CDATA (and notes related to it) is/are
separate from NAME and ID (separate LI elements) and the additional
restrictions on NAME and ID do not apply. Interesting to see semantic
mark-up actually providing additional clarity.

Richard.
Jul 17 '05 #11
I noticed that Message-ID: <od********************************@4ax.com>
from Andy Hassall contained the following:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").


The name attribute of input is not one of the ID or NAME types, so that
restriction doesn't apply.

There are attributes that are declared as ID or NAME; input's name attribute
is not one of them.


You lost me with most of this, but I thought I'd show you the little
problem I had today

This doesn't work

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function checkOne(j) {
box = eval("document.form1." + j);
if (box.checked == false) box.checked = true;
}
</SCRIPT>

<td><select name=\"select".$i."\" onChange=\"checkOne(".$i.")\">

(where $i is a number)

But this does:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function checkOne(j) {
box = eval("document.form1.C" + j);
if (box.checked == false) box.checked = true;
}
</SCRIPT>

where I preface the checkbox name with a C

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #12
Andy Hassall <an**@andyh.co.uk> writes:
The name attribute of input is not one of the ID or NAME types, so that
restriction doesn't apply.

There are attributes that are declared as ID or NAME; input's name attribute
is not one of them.
You seem to be correct.

Checking the DTD of HTML 4.01, only the id attribute is ID, and only
two attributes of the meta tag and the type %Lanuagecode are NAME.

The only thing that bothers me a bit is this:
<URL:http://www.w3.org/TR/html4/struct/global.html#adef-id>
where the id attribute is declared as a (lowercase) "name", which linkes
to <URL:http://www.w3.org/TR/html4/types.html#type-name> (the paragraph on
ID and NAME tokens). According to the DTD, the id should be an ID.
Hmm, I also stubmled over this paragraph:

--- <URL:http://www.w3.org/TR/html4/struct/links.html#anchors-with-id> ---
The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a
single element, their values must be identical.
---

I can't read with absolute certainty whether this restriction is only
on the mentioned elements, and id and name can be distinct on other
elements, but I believe it is only for those mentioned. These elements
are the ones that are represented in Javascript in global collections,
(document.{links,anchors,applets,forms,images}, and window.frames),
so they should be globally unique. Comments?
http://www.w3.org/TR/html4/struct/li...ml#adef-name-A

The name attribute of the <a> tag is of type CDATA, but it says here that it
is restricted to the namespace of the id attribute, which is of type 'name'.


I don't read it as saying the CDATA is *restricted* to the name space
of the id attribute. It says
"Note that this attribute shares the same name space as the id attribute."
Sharing a name space just means that an id attribute and a name attribute
with the same value will conflict, and it isn't allowed.

I can't see anything that prevents the name attribute from containing
characters not possible in an id attribute In fact, in the same
section as the above quote, they explicitly mentions "D&uuml;rst" as a
legal name attribute value for an anchor.
Thanks for pointing this out. I always like to get smarter :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 17 '05 #13
On 30 Sep 2003 13:41:13 -0700, so*****@erols.com (Phil Powell) wrote:
<b>Agency 4</b>
<input type="radio" name="permission[4]" value="1" checked> Yes
<input type="radio" name="permission[4]" value="0" > No
<br>
<b>Agency 5</b>
<input type="radio" name="permission[5]" value="1" checked> Yes
<input type="radio" name="permission[5]" value="0" > No
<br>
I have it set up this way but upon viewing in the browser none of the
radio buttons appear checked.

By the way the radio button names MUST remain in the PHP array format
as they will be referenced EXACTLY like that by PHP on the server end.
Sorry can't change that.

What can I do?

If jou'r using XHTML1 jou have to change
checked
into
checked="checked"

--
Greetz,
De Snor
Jul 17 '05 #14
JRS: In article <aa********************************@4ax.com>, seen in
news:comp.lang.javascript, Geoff Berrow <bl@ckdog.co.uk.the.cat> posted
at Wed, 1 Oct 2003 03:24:10 :-

if (box.checked == false) box.checked = true;


Unless you feel that false might have been redefined, there is no need
to compare with false; there is a NOT operator.

if (!box.checked) box.checked = true;

There may be no need to test that it is not checked before checking it.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 17 '05 #15
I noticed that Message-ID: <72**************@merlyn.demon.co.uk> from Dr
John Stockton contained the following:
if (box.checked == false) box.checked = true;


Unless you feel that false might have been redefined, there is no need
to compare with false; there is a NOT operator.

if (!box.checked) box.checked = true;

There may be no need to test that it is not checked before checking it.


Well that's what you get for nicking bits of code. ;-)

Honestly John, that problem drove me up the wall - I was just happy to
get it working. I had my own code (probably equally as bad) but
scrapped it for something I found on the 'net to get it working. I
guess my own would have worked had I figured out the error.

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #16

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

Similar topics

23
by: Phil Powell | last post by:
<b>Agency 4</b> <input type="radio" name="permission" value="1" checked> Yes <input type="radio" name="permission" value="0" > No <br> <b>Agency 5</b> <input type="radio" name="permission"...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
6
by: juli | last post by:
Hello, I need a control which will contain radio buttons that will be added in a loop. I am using this control a source of some other control. I tried to use group box windows control and to add...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
4
by: Z.K. | last post by:
I started a forms application and I put on the form three buttons. In the functions for the radio buttons I put in a single messagebox like: MessageBox("Hello 1") MessageBox("Hello 2") ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.