« My adwords ads showing in my adsense? || Only allow alpha/numeric characters »

Javascript onfocus-onblur, show-hide table-div

2


For an example, visit SecretTweet.com and click in the textbox up top--the only textbox on the whole page. The captcha, tags field, language field, and submit button all are hidden until needed by the user.

<html>
<head>
<script type="text/JavaScript">
<!--
function showthetable(theTable)
{
      if (document.getElementById(theTable).style.display == 'none')
      {
            document.getElementById(theTable).style.display = 'block';
      }
}
//-->
</script>
</head>
 
<body>
<textarea name="whatever" cols="55" rows="2" onfocus="showthetable('TABLENAME');return true;"></textarea>
 
<div class="options">
<table border="0" cellpadding="0" cellspacing="0">
<tr id="TABLENAME" style="display: none;">
<td>
Hidden content until onfocus!  Hooray!
  </td>
</table>
</div>
 

This entry was posted on Thursday, May 15th, 2008 at 6:17 pm and is filed under Blog, Javascript, WebDev. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Get a Trackback link

2 Comments

  • 很好 March 28, 2009

    Good Code!



  • ashish April 29, 2009

    can we do same thing for textbox without using table to show onblr event of textbox.will send me code. if enter value in textbox is zero thne no need to show new textbox



    Leave a comment