Help - Search - Members - Calendar
Full Version: Site Search
Pixel2Life Forum > Help Section > HTML, XHTML, CSS and General Web Design
thedanphillips
Ok, here's what I'm trying to do, I want to make a search engine for an Intranet site I'm making. I have it coded like this:

CODE
<input type="submit" value="" id="srchbtn" />
<input type="text" value="Search..." id="srchtext" />


What that does it creates a submit button with no value ( I set the width and height to an image I wanted to use for the button and floated it to the left of the text) and a text input field with "Search..." in it. What I want is so when people click into the text input area, the "Search..." dispappears and they can type. What I have now is so when I click to type, I have to backspace the "Search..." before I can enter a keyword.

I tried writing a JavaScript function for it using the "onClick" attribute of HTML, but I honestly don't know shit about JS besides how to do a "hello world!" app lol. So, does anyone have the time to help me out and point me in the right direction? I'd honestly perfer a thorough tutorial, by that I mean one that explains why this bracket is there and why I write this there and blah blah.

Thanks a lot!
Demonslay
CODE
onclick="if(this.value=='Search...'){this.value='';}" onblur="if(this.value==''){this.value='Search...';}"


Add that to the text input you want and it should do as you want. Pretty standard thing you could see on most sites by checking their source code. Actually, I got this from this very page from P2L's search box at the top there. It even goes the extra step to add it back if the field is blank when the user focuses away from it.
thedanphillips
Thanks! Didn't even think of that. Too busy trying to fix a float drop.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.