Results 1 to 2 of 2

Thread: do radio buttons have to be clicked twice when using js

  1. #1
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default do radio buttons have to be clicked twice when using js

    Hi,

    i have a set of radio buttons with some javascript attached to each one. for some reason the javascript only runs on the second click (i.e you have to click once to activate the radio button and click again to run the javascript)

    is this a known issue or is there something strange in my code.

    this happens with all javascript events like onmousedown \ onmouseover \ onclick etc.

    here my code.

    any help appreciated

    andrew


    <tr>
    <td class="form_field" valign='top' align='right'>How Would You Like Paying?</td><td width='10' aligh='right' valign='top'> <font
    size='2' color='#ff0000'>*</font> </td>


    <td class="form_text">
    <input onMouseUp="return paypals()" type="radio" id="charityradio" name="Please_select" value="Donate Funds To Charity" <?php
    formChecked($HTTP_POST_VARS[ "Please_select" ], "Donate Funds To Charity" ); ?> > Donate Funds To Charity (children in need)
    <br>


    <input onMouseUp="return paypals()" type="radio" id="paypalradio" name="Please_select" value="PayPal Payment" <?php
    formChecked( $HTTP_POST_VARS[ "Please_select" ], "PayPal Payment" ); ?>
    > PayPal Payment<br>



    <input onMouseUp="return paypals()" type="radio" id="chequeradio" name="Please_select" value="Cheque" <?php formChecked(
    $HTTP_POST_VARS[ "Please_select" ], "Cheque" ); ?> > Cheque<br>
    </td>
    </tr>
    -------------------------------------------------------------------
    <script type="text/javascript">

    function paypals() {

    chosen = ""
    len = document.frmFormMail.Please_select.length

    for (i = 0; i <len; i++)
    {
    if (document.frmFormMail.Please_select[i].checked)
    {
    chosen = document.frmFormMail.Please_select[i].value
    }
    }

    if (chosen == "")
    {
    //alert("No Location Chosen")
    }
    if (chosen == "Donate Funds To Charity")
    {
    //alert("donate")
    document.getElementById("paypal").style.visibility = "hidden"
    document.getElementById("cheque").style.visibility = "hidden"
    }
    else if (chosen == "PayPal Payment")
    {
    //alert("paypal")
    document.getElementById("paypal").style.visibility = "visible"
    document.getElementById("cheque").style.visibility = "hidden"
    }
    else if (chosen == "Cheque")
    {
    //alert("cheque")
    document.getElementById("paypal").style.visibility = "hidden"
    document.getElementById("cheque").style.visibility = "visible"
    }
    return false
    }
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You should use the onclick event, not the onmouseup. There could be other problems.

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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