Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-12-2005, 02:59 PM
WebProWorld Member
 

Join Date: Jul 2004
Location: 03301
Posts: 29
elso RepRank 0
Default Another quick script question

Hello

I have this text field:
Code:
 <input maxlength=256 size=10 name=q value="Search" onClick=this.value=''>
default text value being "Search". How can I make
this conditional to clear the field only when the
default "Search" text is the value?


Thank you
Nelson
Reply With Quote
  #2 (permalink)  
Old 01-14-2005, 02:58 PM
WebProWorld Member
 

Join Date: Sep 2004
Location: Idaho
Posts: 40
MHenscheid RepRank 0
Default

here is the code I use at www.nrsweb.com


<input class="search" name="w" type="text" value="Search" size="7" onBlur="ClickedAwaySearch(this)" onClick="ClickedSearch(this)">

<script language="JavaScript">
<!--
function ClickedAwaySearch(a)
{
if (a.value=='')
{
a.value='Search';
a.style.color='gray';
}
}

function ClickedSearch(a)
{
if (a.value=='Search')
{
a.value='';
a.style.color='black';
}
}

//-->
</script>
Reply With Quote
  #3 (permalink)  
Old 01-14-2005, 03:00 PM
WebProWorld Member
 

Join Date: Sep 2004
Location: Idaho
Posts: 40
MHenscheid RepRank 0
Default

Hmm...didn't seem to like the javascript I put in there....

Anyway, here are the javascript functions (without the script tags)

function ClickedAwaySearch(a)
{
if (a.value=='')
{
a.value='Search';
a.style.color='gray';
}
}

function ClickedSearch(a)
{
if (a.value=='Search')
{
a.value='';
a.style.color='black';
}
}
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

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

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


Search Engine Optimization by vBSEO 3.2.0