/ Published in: JavaScript
URL: http://facebook-developer.net/2007/12/24/displaying-facebook-like-search-inputs/
Expand |
Embed | Plain Text
<?php define('BLANK_INPUT', 'Click to type');?> <style type="text/css"> input.inputblank { color:#999; } /* class to use for blank input */ fieldset { border:0px; margin:1em; clear:both; } fieldset div.input label { float:left; clear:left; margin-right:5px; width:100px; text-align:right; } fieldset div.input input { float:left; width:200px; margin-bottom:0.25em; } fieldset div.submit input { float:left; clear:left; margin-left:105px; } </style> <script type="text/javascript"><!-- const BLANK_INPUT = '<?php echo addslashes(BLANK_INPUT);?>'; function trim(str) { return str.replace(/^\s+|\s+$/g, ''); } function clearInput(e, compare) { e.removeClassName('inputblank'); // remove grayed out color if (e.getValue() == compare) { e.setValue(''); // clear default text when clicked } } function restoreInput(e, value) { if (trim(e.getValue()) == '') { e.setValue(value); // reset default text when unclicked e.addClassName('inputblank'); // display grayed out color } } //--></script> <form action="?search"> <fieldset> <div class="input"> <label>Keywords:</label> <input name="keywords" type="text" class="inputtext inputsearch inputblank" onfocus="clearInput(this, BLANK_INPUT);" onblur="restoreInput(this, BLANK_INPUT);" value="<?php echo BLANK_INPUT;?>"/> </div> <div class="submit"> <input type="submit" class="inputbutton inputsubmit" value="Search"/> <div> </fieldset> </form>
You need to login to post a comment.
