Jump to content

Help adding field box text to Search Form


Chrisj

Recommended Posts

I have this Form code that works successfully to Search a web site (below).

How can I add text in the field/box that will disappear when the field/box is selected to add search keywords to?

Also, how can I widen the field/box?

Any help/examples/suggestions will be appreciated.

<form method="get" action="search.php">
<div id="siteSearch">
Enter Search Words <img src="themes/default/images/arrow-red.png">  
<input type="hidden" name="type" value="videos"/>
<input type="text" name="keyword" id="sbi1" value="" onfocus="if(this.value==this.defaultValue) this.value='';">
<input type="image" align="middle" src="images/search.png"  name="sa" value="Search" id="mySearch"/><br/>
</div>
</form>

Thanks

Link to comment
Share on other sites

Thanks for your reply, however I tried this and it didn't affect the Form at all:

 

<input type="text" name="keyword" id="sbi1" size="20" placeholder="Enter keywords" value="" onfocus="if(this.value==this.defaultValue) this.value='';">

Any additional help will be appreciated

Link to comment
Share on other sites

It looks like you already have the JavaScript in place. It could be modified as follows:

<input type="text" name="keyword" id="sbi1" value="default value" onfocus="if(this.value=='default value') this.value='';">

You would just need to change both instances of "default value" to whatever you need the default value to be.

 

 

To answer your other question, the input field can be widened with the "size" attribute. More information about the <input> tag and its attributes can be found here:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

Link to comment
Share on other sites

You can use CSS to change the color:

https://www.google.com/search?q=html+input+value+color

 

Of course, that will change the color of any text entered in the input filed. If you only want the placeholder text to be a certain color, you can change it dynamically with JavaScript:

https://www.google.com/search?q=javascript+text+color+style

Link to comment
Share on other sites

Thanks, but with all due respect, I could research this on line via google, but I am hoping to get some specific code help here, on this forum, regarding changing the color of the placeholder text only for this specific line code.

 

Thanks again for any specific help.

Link to comment
Share on other sites

The Google links provide examples on how to accomplish what you're asking. If you try it out and it doesn't work, feel free to post again with the updated code.

 

Otherwise, perhaps someone else is willing to write the code for you. I honestly don't have the time. You could also consider posting something in the Freelancing forum.

http://forums.phpfreaks.com/forum/20-php-freelancing/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.