www.webdeveloper.com
Results 1 to 3 of 3

Thread: Need something like "onClick"

  1. #1
    Join Date
    Apr 2005
    Posts
    4

    Need something like "onClick"

    Lets say I have 5 radio button groups with 2 radio buttons in each group. Lets also say that I have a javascript function that when called, it will check specific radio buttons that I want it to.

    I have a working scenario like the one above, but here's the problem.

    Each radio button has an onClick function within it. When a radio button is clicked, a specific page will open in an iFrame. This also works fine. However, when I use the function that changes all the radio buttons at once, this onClick feature is not used (seems like it's literally when you click it, not when checked is changed from false to true).

    Is there any way to get the same effect as I get with onClick when I'm changing lots of radio button values through a function? Thanks

  2. #2
    Join Date
    Dec 2004
    Location
    KS
    Posts
    147
    sorta like this??

    Code:
    <script>
    function testClick(){
    document.getElementById('opt11').click();
    document.getElementById('opt22').click();
    document.getElementById('opt31').click();
    }
    </script>
    
    
    <input type=radio name=r1 id=opt11 onclick="alert('you clicked '+this.id)">
    <input type=radio name=r1 id=opt12 onclick="alert('you clicked '+this.id)">
    <br>
    <input type=radio name=r2 id=opt21 onclick="alert('you clicked '+this.id)">
    <input type=radio name=r2 id=opt22 onclick="alert('you clicked '+this.id)">
    <br>
    <input type=radio name=r3 id=opt31 onclick="alert('you clicked '+this.id)">
    <input type=radio name=r3 id=opt32 onclick="alert('you clicked '+this.id)">
    <br>
    <input type=button value="simulate click" onclick="testClick()">

  3. #3
    Join Date
    Apr 2005
    Posts
    4
    actually, that's exactly what I needed. Hah Thanks a ton!

    (i was hoping there would be something like .click() ) =P

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles