473,396 Members | 1,847 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.

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="this.className='option_wk_even'; window.status='WEEK 2
'+calNowYear+' Schedule';" onMouseOut="this.className='option_off';
window.status='';"><input type="radio" name="buttons" value="33"
onClick="displaySchedule(this);">
<label style="cursor: hand;"
onClick="document.forms['training'].elements['buttons'][33].click();"><b>WEEK
2</b></label></label></span></td>

Any thoughts as to why this happens?

Thanks,

Paul

Sep 3 '05 #1
3 1939
ma*********@go.com wrote in
news:11**********************@g14g2000cwa.googlegr oups.com:
<span title="WEEK 2"><label
onMouseOver="this.className='option_wk_even'; window.status='WEEK 2
'+calNowYear+' Schedule';" onMouseOut="this.className='option_off';
window.status='';"><input type="radio" name="buttons" value="33"
onClick="displaySchedule(this);">
<label style="cursor: hand;"
onClick="document.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
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: ...
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 ...
2
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"...
3
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...
5
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');...
1
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...
3
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...
7
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. ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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.