Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Check a radio button when clicked on input field
Old 03-24-2010, 12:25 PM Check a radio button when clicked on input field
Junior Talker

Posts: 1
Trades: 0
Hi,

I am new on these forums, I used to use other forums to get some help with some of my stuff but they suddenly disappeared...

So I have the following code:

HTML Code:
<TABLE width="100%" class="shared_table">
    <thead>
        <tr>
            <th class="compare"></th>
            <th class="compare">Selecteer</th>
        </tr>
    </thead>
<TR class="odd">
<td><b>lorem ipsum</b> blabla</td>
<td width="15%"><input type="radio" name="ns" value="nee" checked></td>
</TR>
<TR class="even">
<td><b>blabla</b>
    <table width="100%">
        <tr>
            <td width="50%"><span class="cents">bla 1</span>
            </td>
            <td width="50%"><input name="ns1" type="text" value="">
            </td>
        </tr>
        <tr>
            <td width="50%"><span class="cents">bla 2</span>
            </td>
            <td width="50%"><input name="ns2" type="text" value="">
            </td>
        </tr>
    </table>
</td>
<td width="15%"><input type="radio" name="ns" value="ja"></td>
</TR>
</table>
When one of the input fields is clicked, I want the website to check the last radio button.

So if

HTML Code:
<input name="ns1" type="text" value="">
or if

HTML Code:
<input name="ns2" type="text" value="">
is clicked i want the website to check

HTML Code:
<input type="radio" name="ns" value="ja">
and to uncheck

HTML Code:
<input type="radio" name="ns" value="nee" checked>
How do I achieve this?
PHP_Passion is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-24-2010, 12:45 PM Re: Check a radio button when clicked on input field
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the radio buttons each need an ID (say ns0 & ns1)

Code:
function setRadio() {
     getElementById('ns0).checked = true;
     getElementById('ns1).checked = false;
}
The add an onclick event to the text inputs

onclick="setRadio()"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Check a radio button when clicked on input field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09851 seconds with 12 queries