Connecting Tech Pros Worldwide Help | Site Map

Problem with hiding div inside table

  #1  
Old February 28th, 2007, 03:37 PM
ashsa's Avatar
Member
 
Join Date: Feb 2007
Location: New Delhi, India
Posts: 43
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 ??
  #2  
Old February 28th, 2007, 05:36 PM
Member
 
Join Date: Feb 2007
Posts: 36

re: Problem with hiding div inside table


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
  #3  
Old March 1st, 2007, 10:58 AM
ashsa's Avatar
Member
 
Join Date: Feb 2007
Location: New Delhi, India
Posts: 43

re: Problem with hiding div inside table


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
  #4  
Old March 2nd, 2007, 08:43 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,521
Provided Answers: 12

re: Problem with hiding div inside table


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.
  #5  
Old January 6th, 2009, 07:23 PM
Newbie
 
Join Date: Jan 2009
Posts: 1

re: Problem with hiding div inside table


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIV positioning fine in Firefox but out of place in IE TheCeej answers 4 October 2nd, 2006 07:52 PM
Problems with div and Panel with VS tshad answers 4 September 22nd, 2006 08:05 PM
Table Margin Inside Multiple Div Problem on IE tbcarver@yahoo.com answers 10 August 17th, 2005 06:15 PM
What can be inside a div? Falc2199 answers 15 July 23rd, 2005 12:32 PM