By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

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

P: 3
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:

Expand|Select|Wrap|Line Numbers
  1. <asp:Checkbox ID="chekID_One" onchange="hide_Ctrls('one')" Checked="false" runat="server"></asp:Checkbox>
  2. <asp:Checkbox ID="chekID_Two" onchange="hide_Ctrls('two')" Checked="false" runat="server"></asp:Checkbox>
  3.  
  4. <script language="JavaScript" type="Text/Javascript">
  5. if(value == 'one')
  6. {
  7. var getOne = document.getElementById('chekID_One').checked;    
  8.  
  9. if(getOne == true)
  10. {                
  11. document.getElementById('trOne').style.visibility = "collapse";                
  12. }
  13. else
  14. {
  15. document.getElementById('trOne').style.visibility = "visible";
  16. }
  17. }
  18. </script>
  19.  
This code is working fine in firefox. But not in IE and Safari.
Can anyone tell why is it so???

Plzzz help me...
Jan 25 '08 #1
Share this Question
Share on Google+
4 Replies


gits
Expert Mod 5K+
P: 5,329
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
Jan 27 '08 #2

P: 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:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="Text/Javascript">
  2. function hide_Ctrls()
  3. {
  4.     if(value == 'one')
  5.     {
  6.     var getOne = document.getElementById('chekID_One').checked; 
  7.  
  8.     if(getOne == true)
  9.     {            
  10.     document.getElementById('trOne').style.visibility = "collapse";    
  11.     }
  12.     else
  13.     {
  14.     document.getElementById('trOne').style.visibility = "visible";
  15.     }
  16. }
  17. </script>
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
Jan 28 '08 #3

P: 41
hi,

Use Div for it...

javascript
Expand|Select|Wrap|Line Numbers
  1. function hide_Ctrls()
  2. {
  3.  
  4.         var getOne = document.getElementById('chekID_One').checked;
  5.  
  6.         if(getOne == true)
  7.         { 
  8.             alert('divone none');
  9.             document.getElementById('divone').style.display  = 'none'; 
  10.         }
  11.         else
  12.         {
  13.             alert('divone hidden');
  14.             document.getElementById('divone').style.display = '';
  15.         }
  16.  
  17.         getOne = document.getElementById('chekID_Two').checked;        
  18.  
  19.         if(getOne == true)
  20.         { 
  21.             alert('divtwo none');
  22.             document.getElementById('divtwo').style.display  = 'none'; 
  23.         }
  24.         else
  25.         {
  26.             alert('divtwo hidden');
  27.             document.getElementById('divtwo').style.display = '';
  28.         }
  29.  
  30. }
  31.  
  32.  
  33. Question1 <asp:Checkbox ID="chekID_One" onClick="hide_Ctrls('one')" Checked="false" runat="server"></asp:Checkbox>
  34.         <div id='divone'>
  35.             This is the answer of Question1
  36.         </div>
  37.         Question2<asp:Checkbox ID="chekID_Two" onClick="hide_Ctrls('two')" Checked="false" runat="server"></asp:Checkbox>
  38.        <div id='divtwo'>This is the answer of Question2</div>
  39.  

Hope this will help... Thanks
Jan 28 '08 #4

P: 3
Hi,

Ya its working fine now.

Thanks... :-)


hi,

Use Div for it...

javascript
Expand|Select|Wrap|Line Numbers
  1. function hide_Ctrls()
  2. {
  3.  
  4.         var getOne = document.getElementById('chekID_One').checked;
  5.  
  6.         if(getOne == true)
  7.         { 
  8.             alert('divone none');
  9.             document.getElementById('divone').style.display  = 'none'; 
  10.         }
  11.         else
  12.         {
  13.             alert('divone hidden');
  14.             document.getElementById('divone').style.display = '';
  15.         }
  16.  
  17.         getOne = document.getElementById('chekID_Two').checked;        
  18.  
  19.         if(getOne == true)
  20.         { 
  21.             alert('divtwo none');
  22.             document.getElementById('divtwo').style.display  = 'none'; 
  23.         }
  24.         else
  25.         {
  26.             alert('divtwo hidden');
  27.             document.getElementById('divtwo').style.display = '';
  28.         }
  29.  
  30. }
  31.  
  32.  
  33. Question1 <asp:Checkbox ID="chekID_One" onClick="hide_Ctrls('one')" Checked="false" runat="server"></asp:Checkbox>
  34.         <div id='divone'>
  35.             This is the answer of Question1
  36.         </div>
  37.         Question2<asp:Checkbox ID="chekID_Two" onClick="hide_Ctrls('two')" Checked="false" runat="server"></asp:Checkbox>
  38.        <div id='divtwo'>This is the answer of Question2</div>
  39.  

Hope this will help... Thanks
Jan 28 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.