WordPress.org

Ready to get started?Download WordPress

Forums

making default text field value disappear on focus (1 post)

  1. ranebo
    Member
    Posted 6 years ago #

    I had had my search field working so that the default text displayed in the field would disappear when the field was clicked. The default text would reappear if the field lost focus.

    Somehow this no longer works. Now the default text is displayed _outside_ the search field. (The search function still works properly, it is just the display of the default text that is no longer working.)

    Here is the code I have in the head of index.php:

    <script type="text/javascript">
    function clearText(input){
    if (input.defaultValue==input.value)
    input.value = ''
    }
    </script>

    onfocus="clearText(this)"

    <script type="text/javascript">
    function restoreText(input){
    if (input.value=='')
    input.value = input.defaultValue
    }
    </script>

    onblur="restoreText(this)"

    Here is the code I have in what functions as my (manual) sidebar:

    <span title="click to open/close">
    <h3 class="pointandclick" onClick="toggleContent('mySearchList')">search</h3>
    </span>
    <div id="mySearchList" style="display: none; color: #666666">

      <li id="search">
      <label for="s"><?php _e('enter search term'); ?></label>
      <form id="searchform" method="get" action="<?php echo $PHP_SELF; ?>">
      <div>
      <input type="text" name="s" id="s" size="15" />
      <input type="submit" name="submit" value="<?php _e('search'); ?>" />
      </div>
      </form>

    </div>

    Any suggestions most gratefully received!

    -- http://inrockland.us

Topic Closed

This topic has been closed to new replies.

About this Topic