JavaScript function is working only in FIreFox Not in IE and Safari

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simikc
    New Member
    • Jan 2008
    • 3

    JavaScript function is working only in FIreFox Not in IE and Safari

    Hi,

    I am using a javascript function for hiding a particular html row while clicking the check box.
    Each row corresponds to different checkbox.

    The code I have used is:

    [CODE=javascript]<asp:Checkbox ID="chekID_One " onchange="hide_ Ctrls('one')" Checked="false" runat="server"> </asp:Checkbox>
    <asp:Checkbox ID="chekID_Two " onchange="hide_ Ctrls('two')" Checked="false" runat="server"> </asp:Checkbox>

    <script language="JavaS cript" type="Text/Javascript">
    if(value == 'one')
    {
    var getOne = document.getEle mentById('chekI D_One').checked ;

    if(getOne == true)
    {
    document.getEle mentById('trOne ').style.visibi lity = "collapse";
    }
    else
    {
    document.getEle mentById('trOne ').style.visibi lity = "visible";
    }
    }
    </script>
    [/CODE]

    This code is working fine in firefox. But not in IE and Safari.
    Can anyone tell why is it so???

    Plzzz help me...
    Last edited by gits; Jan 27 '08, 02:05 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    do you get any error message in IE or safari? could you post your hide_Ctrls() function?

    ahh ... and i think to hide something you should use 'hidden' as the value for visibility

    kind regards

    Comment

    • simikc
      New Member
      • Jan 2008
      • 3

      #3
      Hi,

      No I am not getting any error in IE or Safari. And while using 'hidden' it just make the visibility hidden. The space will be there. Thats why I used 'collapse' which will hide the controls as well as space.
      And the hide_Ctrls() function is:

      [CODE=javascript]<script language="JavaS cript" type="Text/Javascript">
      function hide_Ctrls()
      {
      if(value == 'one')
      {
      var getOne = document.getEle mentById('chekI D_One').checked ;

      if(getOne == true)
      {
      document.getEle mentById('trOne ').style.visibi lity = "collapse";
      }
      else
      {
      document.getEle mentById('trOne ').style.visibi lity = "visible";
      }
      }
      </script>[/CODE]

      Originally posted by gits
      do you get any error message in IE or safari? could you post your hide_Ctrls() function?

      ahh ... and i think to hide something you should use 'hidden' as the value for visibility

      kind regards
      Last edited by gits; Jan 28 '08, 07:30 AM. Reason: added code tags

      Comment

      • leoiser
        New Member
        • Jul 2007
        • 41

        #4
        hi,

        Use Div for it...

        javascript
        [CODE=asp]function hide_Ctrls()
        {

        var getOne = document.getEle mentById('chekI D_One').checked ;

        if(getOne == true)
        {
        alert('divone none');
        document.getEle mentById('divon e').style.displ ay = 'none';
        }
        else
        {
        alert('divone hidden');
        document.getEle mentById('divon e').style.displ ay = '';
        }

        getOne = document.getEle mentById('chekI D_Two').checked ;

        if(getOne == true)
        {
        alert('divtwo none');
        document.getEle mentById('divtw o').style.displ ay = 'none';
        }
        else
        {
        alert('divtwo hidden');
        document.getEle mentById('divtw o').style.displ ay = '';
        }

        }


        Question1 <asp:Checkbox ID="chekID_One " onClick="hide_C trls('one')" Checked="false" runat="server"> </asp:Checkbox>
        <div id='divone'>
        This is the answer of Question1
        </div>
        Question2<asp:C heckbox ID="chekID_Two " onClick="hide_C trls('two')" Checked="false" runat="server"> </asp:Checkbox>
        <div id='divtwo'>Thi s is the answer of Question2</div>
        [/CODE]


        Hope this will help... Thanks
        Last edited by gits; Jan 28 '08, 07:32 AM. Reason: added code tags

        Comment

        • simikc
          New Member
          • Jan 2008
          • 3

          #5
          Hi,

          Ya its working fine now.

          Thanks... :-)


          Originally posted by leoiser
          hi,

          Use Div for it...

          javascript
          [CODE=asp]function hide_Ctrls()
          {

          var getOne = document.getEle mentById('chekI D_One').checked ;

          if(getOne == true)
          {
          alert('divone none');
          document.getEle mentById('divon e').style.displ ay = 'none';
          }
          else
          {
          alert('divone hidden');
          document.getEle mentById('divon e').style.displ ay = '';
          }

          getOne = document.getEle mentById('chekI D_Two').checked ;

          if(getOne == true)
          {
          alert('divtwo none');
          document.getEle mentById('divtw o').style.displ ay = 'none';
          }
          else
          {
          alert('divtwo hidden');
          document.getEle mentById('divtw o').style.displ ay = '';
          }

          }


          Question1 <asp:Checkbox ID="chekID_One " onClick="hide_C trls('one')" Checked="false" runat="server"> </asp:Checkbox>
          <div id='divone'>
          This is the answer of Question1
          </div>
          Question2<asp:C heckbox ID="chekID_Two " onClick="hide_C trls('two')" Checked="false" runat="server"> </asp:Checkbox>
          <div id='divtwo'>Thi s is the answer of Question2</div>
          [/CODE]


          Hope this will help... Thanks

          Comment

          Working...