Home News Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | HTML/JS Help (radio buttons)


You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Cable Forum Basement > Lifestyle

HTML/JS Help (radio buttons)
Reply
 
Thread Tools
Old 12-07-2010, 16:38   #1
AbyssUnderground
cf.mega poster
 
AbyssUnderground's Avatar
 
Join Date: Oct 2005
Location: Merseyside
Age: 23
Services: Be*Unlimited ADSL Upto 24Mbps, Actual Sync 9Mbps/1.25Mbps, Actual Speed 8.3Mbps/1Mbps. Moving to BT
Posts: 2,071
AbyssUnderground has reached the bronze age
AbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze age
Send a message via MSN to AbyssUnderground
HTML/JS Help (radio buttons)

A long time programmer here for some help, what are the chances?

Something I've never done before, and I need to do it now (well rather a friend does). Basically the radio button (the ones that have the dot in them, not a tick), we have about 80 of them on a page, in groups of 5, in a table each in their own <td>.

What we want to do is be able to click the <td> element of the table (which is large compared to the radio button) and have it select the radio button, rather than having to click on the button itself which can be too fiddly and time consuming.

Does anyone know how to do this? I tried using <label for="radio_id"> but that only works on text but the <td>, as the <td> is a higher element than <label> is.

Any and all help welcomed and appreciated.

Thanks all,

Andy.
__________________
Fancy testing Windows Operating System Betas? Get free Windows Beta Downloads at BetaArchive.com*
*Requires registering and participation in the community.
www.stopthebroadbandcon.org
AbyssUnderground is offline   Reply With Quote
Advertisement
Old 12-07-2010, 16:56   #2
haydnwalker
cf.mega poster
Tetris Champion
 
haydnwalker's Avatar
 
Join Date: Jan 2007
Location: Doncaster, S. Yorks.
Age: 28
Services: TV:Sky+, BB:DRL VDSL2 40/10 with Ask4, Phone:Mobile Only
Posts: 2,227
haydnwalker has reached the bronze age
haydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze agehaydnwalker has reached the bronze age
Re: HTML/JS Help (radio buttons)

Quick google turned up this ==> http://www.dynamicdrive.com/forums/a...hp/t-3302.html should be what you want
__________________
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein

haydnwalker is offline   Reply With Quote
Old 12-07-2010, 17:05   #3
punky
Gone
Alpha Bravo Charlie Champion
 
Join Date: Jun 2003
Age: 31
Posts: 14,760
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: HTML/JS Help (radio buttons)

Something like this...

Code:
<head>
    <script language="javascript">
        function setRadio(t) {

            t.getElementsByTagName("input")[0].checked = true;
        
        }
    </script>
</head>
And then in the table rows:

Code:
    <tr><td onclick="javascript:setRadio(this)">
        <input id="Radio1" type="radio" value="Radio1" />Test value</td><td>Something else</td></tr>
    <tr><td onclick="javascript:setRadio(this)">
        <input id="Radio2" type="radio" value="Radio2" />Test value 2</td><td>Something else 2</td></tr>
Assuming that the radio is the first input element in the table cell.

HTH

Last edited by punky; 12-07-2010 at 17:11.
punky is offline   Reply With Quote
Old 12-07-2010, 23:52   #4
Matth
cf.mega poster
 
Join Date: Mar 2004
Posts: 1,973
Matth has reached the bronze age
Matth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze age
Re: HTML/JS Help (radio buttons)

Combine the scripted TD method with the LABEL one, as the LABEL way will remain active even if script is disabled - always try to fail gracefully!

http://stackoverflow.com/questions/2...-its-parent-td
Similar question, with some solutions that are pure CSS (no script!).
Matth is offline   Reply With Quote
Old 13-07-2010, 09:14   #5
AbyssUnderground
cf.mega poster
 
AbyssUnderground's Avatar
 
Join Date: Oct 2005
Location: Merseyside
Age: 23
Services: Be*Unlimited ADSL Upto 24Mbps, Actual Sync 9Mbps/1.25Mbps, Actual Speed 8.3Mbps/1Mbps. Moving to BT
Posts: 2,071
AbyssUnderground has reached the bronze age
AbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze ageAbyssUnderground has reached the bronze age
Send a message via MSN to AbyssUnderground
Re: HTML/JS Help (radio buttons)

Cheers guys, I think the last posts solution is the best one for compatibility. Rep on the way.
__________________
Fancy testing Windows Operating System Betas? Get free Windows Beta Downloads at BetaArchive.com*
*Requires registering and participation in the community.
www.stopthebroadbandcon.org
AbyssUnderground is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Google Search




All times are GMT +1. The time now is 07:16.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Copyright © 2003 - 2012, Cable Forum.
(server1.cableforum.co.uk)

SEO by vBSEO 3.3.2