on clickevent not working in ff and safari

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • indu24
    New Member
    • Feb 2008
    • 2

    on clickevent not working in ff and safari

    hello,
    i found this code for onclick event on radio buttons. but it is not workinf for firefox and safari but it does for IE.
    actually there r 2 sets of radiobuttons. the second works but not the first set in firefox and safari plz help me.urgent!!

    [HTML]<input type="radio" name="Radio2" value="r17" id="accept2"
    onclick="docume nt.getElementBy Id('dropdown1') .style.display ='none',documen t.getElementByI d('dropdown').s tyle.display ='block', document.getEle mentById('decli ne').checked = 0" checked="checke d" />
    <input type="radio" name="Radio2" value="r18" id="decline2"
    onclick="docume nt.getElementBy Id('dropdown'). style.display ='none', document.getEle mentById('dropd own1').style.di splay = 'block', document.getEle mentById('accep t2').checked = 0" />

    <input align="top" id="decline1" onClick="docume nt.getElementBy Id('dropdown3') .style.display = 'none', document.getEle mentById('accep t1').checked = 0" name="Radio1" type="radio" value="12" />

    <input name="Radio1" type="radio" value="13" id="accept1" checked="checke d"
    onClick="docume nt.getElementBy Id('dropdown3') .style.display = 'block', document.getEle mentById('decli ne1').checked = 0"/>[/HTML]
    Last edited by gits; Feb 29 '08, 07:42 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    try checked = true or false instead ...

    kind regards

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Actually, it's just 'checked'. No = required.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by drhowarddrfine
        Actually, it's just 'checked'. No = required.
        You're probably talking about the HTML while gits was referring to the JavaScript.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          yup ... there are 2 possibilities that sometimes are mixed up in some code ... what is a bad practice :) ... so we should decide for ONE way of the following:

          1. setting the javascript property:

          [CODE=javascript]node.property = 'property_value ';[/CODE]
          2. setting the attribute:

          [CODE=javascript]node.setAttribu te('attr_name', 'attr_value');[/CODE]
          usage examples:

          [CODE=javascript]// assume my_id is the id of a textbox (<input type="text" id="my_id"/>)
          var node = document.getEle mentById('my_id ');

          // using readonly for the example
          // 1. way:

          // make it readonly
          node.readonly = true;

          // make it editable
          node.readonly = false;

          // 2. way:

          // make it readonly
          node.setAttribu te('readonly', 'readonly');

          // make it editable
          node.removeAttr ibute('readonly ');
          [/CODE]
          kind regards

          Comment

          Working...