473,800 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird span/radio button/JavaScript behavior...

Can anyone help me to figure out a strange span/radio button/JavaScript
behavior?

When clicking on the radio button for WEEK 2 below all works okay, but
when clicking on the label for the same week, button 41 gets selected
instead:

<td align="center">
<span title="WEEK 2"><label
onMouseOver="th is.className='o ption_wk_even'; window.status=' WEEK 2
'+calNowYear+' Schedule';" onMouseOut="thi s.className='op tion_off';
window.status=' ';"><input type="radio" name="buttons" value="33"
onClick="displa ySchedule(this) ;">
<label style="cursor: hand;"
onClick="docume nt.forms['training'].elements['buttons'][33].click();"><b>W EEK
2</b></label></label></span></td>

Any thoughts as to why this happens?

Thanks,

Paul

Sep 3 '05 #1
3 1958
ma*********@go. com wrote in
news:11******** **************@ g14g2000cwa.goo glegroups.com:
<span title="WEEK 2"><label
onMouseOver="th is.className='o ption_wk_even'; window.status=' WEEK 2
'+calNowYear+' Schedule';" onMouseOut="thi s.className='op tion_off';
window.status=' ';"><input type="radio" name="buttons" value="33"
onClick="displa ySchedule(this) ;">
<label style="cursor: hand;"
onClick="docume nt.forms['training'].elements['buttons'][33].click();"

^^^^^^^^^^^^^^^ ^^^^^^^^

I have to wonder about how you're referencing the radio element (and why
there is only one radio element). According to one site looked at:

All Radio objects are stored in the elements array of the corresponding
form. You can access a Radio object by indexing this array - either by
number (0 represents the first element in a form) or by using the value of
the name attribute.

My guess is that it's treating the 33 as an index into the array and not as
the value of the radio element. Try putting quotes around it or give each
radio object an id and reference it by id.
Sep 3 '05 #2
On 03/09/2005 10:04, ma*********@go. com wrote:

[snip]
When clicking on the radio button for WEEK 2 below all works okay, but
when clicking on the label for the same week, button 41 gets selected
instead:
[snip]
</label></label>


[snip]

Fix your markup; LABEL elements cannot be nested.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Sep 3 '05 #3
John,

Thanks for the reply.

You got me thinking - all of the elements of the array had been sorted
differently, but they were displayed consecutively. After I renumbered
the array elements based upon their order within the HTML, all is fine
now!!

I had 51 radio buttons in a table:

radio value 1 radio value 26
radio value 2 radio value 27
radio value 3 radio value 28

& so on, but each of the <tr><td> code order was causing the confusion.
Doing the following fixed it:

radio value 1 radio value 2
radio value 3 radio value 4
radio value 5 radio value 6

Thanks again.

Paul

Sep 3 '05 #4

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

Similar topics

1
6219
by: David Wake | last post by:
I have two radio buttons and two checkboxes in a form. I'm trying to write some code so that when a radio button is selected, its corresponding checkbox is disabled. My code looks like this: function radioClicked(index) { document.table_config_form.my_checkbox.disabled = true;
6
3295
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 The problem i am facing is that i do not know how many yes/no radio groups will be generated
2
1772
by: tshad | last post by:
I have 2 radio buttons: <asp:RadioButton ID="radDetail" GroupName="detailSummary" Text="Detail" checkedChanged="RadDetail_Clicked" runat="server" /> <asp:RadioButton ID="radSummary" GroupName="detailSummary" Text="Summary" checkedChanged="RadSummary_Clicked" runat="server" /> </p> I want to have RadDetail_Click or RadSummary_Click executed as soon as the radio button is clicked.
3
2074
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way (trick, custom RadioButton, or javascript) to make radio button (radio1) belong to 2 independent radio button groups instead of one? This would be an equivalent of sayting something like radio1.GroupName1 = "GroupA"; radio1.GroupName2 = "GroupB";
5
3254
by: ste.paoletti | last post by:
I have a problem with css I have a this xhtml code: <span> <span> <span/> <input type="radio"/> .... <span/> <input type="button" onclick ="var s=document.createElement('span'); this.previousSibling.firstChild.appendChild(s); "/>
1
2979
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio button of the list you want to use. I'm using JavaScript to automatically select the radio button corresponding to a list when you click on the list (using the onclick event handler). Is that the best event to change on, or should this
3
5848
by: Harry Haller | last post by:
I have a radio button group. When the page loads none of them are selected. OnClick selects ONE and clicking another one selects a different one - this is normal behavior. I want to modify it so that clicking on a radio which is already selected will deselect it so that none of the group are selected. I can get the required behavior with a double-click: ondblclick="this.checked=!(this.checked);"
7
2345
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. Is that so?
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
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 we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.