There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: Forms, Default Values & JavaScript


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
pcpro17's Avatar
Senior Member with 233 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Advanced
12-Jun-2007, 01:47 PM #1
Red face Solved: Forms, Default Values & JavaScript
Hello folks! I'm working on customizing a search form on my site; very simple; one text field. However, I'm having a little trouble getting the field value to deault to something like, "Enter Search Text Here."

Here's the form:
Code:
<div class="searchform">
  <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <input type="text" value="<?php the_search_query(); ?>" name="wpsearchform" id="wpsearchform" />
  </form>
</div>
I seem to remember doing this years ago with JavaScript, but for the life of me I can't remember how it's done now! ^_^;; Any suggestions would be greatly appreciated!
Big-K's Avatar
Distinguished Member with 6,883 posts.
 
Join Date: Nov 2003
Location: Kansas
Experience: Advanced
12-Jun-2007, 07:22 PM #2
that code is correct, you might want to make sure that the information you're putting in the value field actually exists. try loading the page then looking in the generated code to make sure. Also, i notice you have an unneeded / before the end of your action tag.
pcpro17's Avatar
Senior Member with 233 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Advanced
12-Jun-2007, 08:32 PM #3
Hi Big. Yes, I understand that the code I already posted is correct; I copied it out of the WordPress theme that I am modifying. I would like to add some code to it, so that when the page is rendered something like "Enter Search Text Here" is loaded into the field by default.
Big-K's Avatar
Distinguished Member with 6,883 posts.
 
Join Date: Nov 2003
Location: Kansas
Experience: Advanced
12-Jun-2007, 10:22 PM #4
ah, change value="<?php the_search_query(); ?>" to value="Enter Search Text Here", if you want that. I don't know wordpress well, so that might screw with something else, but its worth a try.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,202 posts.
 
Join Date: Oct 2006
13-Jun-2007, 04:45 AM #5
onfocus="if (this.value == 'Enter Search Text Here') this.value = '';"
pcpro17's Avatar
Senior Member with 233 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Advanced
19-Jun-2007, 10:59 AM #6
This issue is now resolved:
Code:
<div class="search">
  <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <input class="search" type="text" onFocus="this.value=''" onBlur="this.value='Search...'" value="Search..." name="s" id="s" />
  </form>
</div>
Thanks everyone for the help!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:54 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.