Connecting Tech Pros Worldwide Help | Site Map

Problem with hiding div inside table

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 28th, 2007, 02:37 PM
ashsa's Avatar
Member
 
Join Date: Feb 2007
Location: New Delhi, India
Posts: 43
Default Problem with hiding div inside table

I use the following fragment in my html page and I tried using the document.getElementById().style.display='none' to hide the div or the row but neither works..

<table>
<form>
<tr id='myrow'>
<td><div id="divi" title='mydiv'></div></td>
</tr>
</form>
</table>

<input type="submit" name='go' value="Go" onclick='reset();return false;'>

function reset(){
document.getElementById('txt1').value="";
document.getElementById('txt2').value="";
document.getElementById('myrow').style.display='no ne';
alert('hidden!!');
}

The functions empties the textboxes but doesnt hide the row or div and also no alert is given !! Could anyone help ??
Reply
  #2  
Old February 28th, 2007, 04:36 PM
Member
 
Join Date: Feb 2007
Posts: 34
Default

I got it to work like this in IE7:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3.  
  4. <head>
  5. <title>Test</title>
  6. </head>
  7.  
  8. <body>
  9. <table>
  10. <form>
  11. <tr id='myrow'>
  12. <td><div id="divi" title='mydiv'>Text Here</div></td>
  13. </tr>
  14. </form>
  15. </table>
  16. <input type="text" name="txt1">
  17. <input type="text" name="txt2">
  18. <input type="submit" name='go' value="Go" onclick='reset();return false;'>
  19. </body>
  20.  
  21. <script language="javascript">
  22. function reset(){
  23. document.getElementById('txt1').value="";
  24. document.getElementById('txt2').value="";
  25. document.getElementById('myrow').style.display='none';
  26. alert('hidden!!');
  27. }
  28. </script>
  29.  
  30. </html>
  31.  
  32.  
Were you forgetting the <script> tag on the java. Try it and see what you get.

Hope it helps
Reply
  #3  
Old March 1st, 2007, 09:58 AM
ashsa's Avatar
Member
 
Join Date: Feb 2007
Location: New Delhi, India
Posts: 43
Default

Thank you Movie King !!
The same thing worked on my System at last :-)
After breaking my head with the prob for about six hours I found that there seems to be an inbuilt function named reset() which i was using for my function ..

Just changed the name of the function and it started working ...

Quote:
Originally Posted by movieking81
I got it to work like this in IE7:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3.  
  4. <head>
  5. <title>Test</title>
  6. </head>
  7.  
  8. <body>
  9. <table>
  10. <form>
  11. <tr id='myrow'>
  12. <td><div id="divi" title='mydiv'>Text Here</div></td>
  13. </tr>
  14. </form>
  15. </table>
  16. <input type="text" name="txt1">
  17. <input type="text" name="txt2">
  18. <input type="submit" name='go' value="Go" onclick='reset();return false;'>
  19. </body>
  20.  
  21. <script language="javascript">
  22. function reset(){
  23. document.getElementById('txt1').value="";
  24. document.getElementById('txt2').value="";
  25. document.getElementById('myrow').style.display='none';
  26. alert('hidden!!');
  27. }
  28. </script>
  29.  
  30. </html>
  31.  
  32.  
Were you forgetting the <script> tag on the java. Try it and see what you get.

Hope it helps
Reply
  #4  
Old March 2nd, 2007, 07:43 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,232
Default

Quote:
Originally Posted by ashsa
Thank you Movie King !!
The same thing worked on my System at last :-)
After breaking my head with the prob for about six hours I found that there seems to be an inbuilt function named reset() which i was using for my function ..

Just changed the name of the function and it started working ...
Yes, never use reserved words used in forms and other places, e.g. name, submit, reset, action...

They cause problems in IE, and anyway it's bad practice.
Reply
  #5  
Old January 6th, 2009, 06:23 PM
Newbie
 
Join Date: Jan 2009
Posts: 1
Default

If you are having trouble tracking down errors, make sure any functions that are case-sensitive, such as getElementById(), are typed correctly.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.