views:

585

answers:

3

Hi,

I have two forms, one with a radio button that users must select to edit. [form name="A"]

  • [input type="radio" name="BookItem" value="1" /]
  • [input type="radio" name="BookItem" value="2" /]
  • [input type="radio" name="BookItem" value="3" /]
  • [form]

    After "BookItem" is selected from form (A) I call the $("#EditFormWrapper").load("callEditData.cfm? ID="+ID); function to load the second form (B)

    [form id="editForm" name="B"]

  • 2 Hours AM
  • 2 Hours PM
  • 2 Hours AM
  • 2 Hours PM
  • [input type="image" src="images/submit-btn.gif" id="addBTN" name="addBTN" class="buttons" alt="SubmitRrequest" /] [input type="image" src="images/cancel-btn.gif" id="editBTNcancel" name="editBTNcancel" class="buttons" alt="Cancel Request" /] [/form] I want to uncheck the radio button on form (A) when user click on cancel button (editBTNcancel) in form(B).

    Here s my script:
    $("#editBTNcancel").live("click", function(event){ event.preventDefault(); $("#EditFormWrapper").slideUp("fast").empty(); //$('.TOR2Hours').removeAttr('checked'); $('.TOR2Hours').attr('checked', false); });

    I hope I clearly state my problem, any suggestion would be greatly appreciated!

    +2  A: 

    I'm not sure exactly what you want but you might try using a reset input.

    <input type='reset' />
    
    jeremysawesome
    totaly agree, or as i answered not a control, but `reset` event
    vittore
    thank for your response, but the radio button is not in the same form so this wouldn't work.
    @user281867: call `reset` for the form radio buttons are in. `document.getElementById("radiobuttonsform").reset();`
    vittore
    THANKS Vittore, this document.getElementById("radiobuttonsform").reset(); works!!!
    A: 

    at first, if you need to clear whole form, there is form event reset also try $('.TOR2Hours').val('')

    vittore
    Thanks, Ihave tried all three of these method with no luck.//$('.TOR2Hours').removeAttr('checked');//$('.TOR2Hours').attr('checked', false);//$('.TOR2Hours').val('')
    A: 

    Seeing as this is pretty much the easiest DOM task there is and works in every scriptable browser, I suggest not using the jQuery methods for it:

    $(".TOR2Hours")[0].checked = false;
    

    The other thing that ocurs to me is whether your selector is correct. Did you mean to select a set of elements by class or should it be an ID selector?

    Tim Down