87dave87 Posted February 7, 2007 Share Posted February 7, 2007 Hi, I have a text box which contains a default value which disappears when a user clicks into it to type something: - <form method="post" action="/search.php" onsubmit="return dis(this)"> <a href="/"><strong>Home</strong></a><strong> | <a href="/about.php#bookmark">Bookmark Us</a> | Find Emulator:</strong> <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='';"> <input type="submit" value="Go"> </form> What code do I need to use to make it so that if the user clicks out of the box it displays the 'e.g. Stella' again? I know its something to do with default value... but can'tfind the code to use. Thanks. Quote Link to comment Share on other sites More sharing options...
slough Posted February 7, 2007 Share Posted February 7, 2007 <form method="post" action="/search.php" onsubmit="return dis(this)"> <a href="/"><strong>Home</strong></a><strong> | <a href="/about.php#bookmark">Bookmark Us</a> | Find Emulator:</strong> <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="this.value='e.g. Stella or Atari 2600';"> <input type="submit" value="Go"> </form> Quote Link to comment Share on other sites More sharing options...
87dave87 Posted February 7, 2007 Author Share Posted February 7, 2007 Hi, ive tried inserting that code but now my search won't find the results. Try typing 'stella' into the top search box @ http://www.emulators.cc/ Quote Link to comment Share on other sites More sharing options...
fenway Posted February 7, 2007 Share Posted February 7, 2007 Well, you only need to change it onblur if it's the defaultValue... Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted February 8, 2007 Share Posted February 8, 2007 <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';"> I search 'stella' and it returned a result the result of your search will be an issue with the search script - this js for controlling the default value won't affetc it... Quote Link to comment Share on other sites More sharing options...
87dave87 Posted February 8, 2007 Author Share Posted February 8, 2007 <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';"> I search 'stella' and it returned a result the result of your search will be an issue with the search script - this js for controlling the default value won't affetc it... How do i make it so that when I click into the box all the default text disappears? at the moment you have to delete it yourself. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 8, 2007 Share Posted February 8, 2007 That was the original reply.... Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted February 8, 2007 Share Posted February 8, 2007 Yeah its in the firts reply - I simply made an adjustment to the onblur but deleted the other - sorry Here it is in all its glory <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='' onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';"> Quote Link to comment Share on other sites More sharing options...
trecool999 Posted February 10, 2007 Share Posted February 10, 2007 You may want to get the links working before you start building the search for it . All I get are 404's... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.