Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idrewuk

macrumors regular
Original poster
Aug 15, 2008
208
120
Hi,

I'm trying to get a little bit of code to work on my site. It's to have a text box prefilled with 'Your email address'. You click, it disappears. You click out, it comes back.

Hard to explain but hopefully the code will help. It's not showing up for some reason and only works if you click inside the box and back out again. Am I missing something obvious?

PHP:
<form action='http://url/form.cgi' method='post'>
<input type='hidden' name='list' value='Form Name'/>
<input type='hidden' name='redirect-success' value='http://www.url.co.uk/complete.html'/>
<br/>
<input type='text' name='email' onfocus="if(this.value=='Your email address')this.value='';this.className='Focus'" onblur="if(this.value=='')this.value='Your email address';this.className='Blur'" class="Blur" /><br/>
<input type='hidden' name='action' value='add'/><input type="image" src="/img/homepage/image.jpg" alt="" class='button' />
</form>

Does this make sense to anybody? This is all I have to make it work - as far as I know there's no external .js file needed?
 
Last edited by a moderator:

ergdegdeg

Moderator emeritus
Oct 13, 2007
1,628
0
You first have to set the placeholder value of your input field like this:

PHP:
<input type="text" value="Your E-Mail address here" />
 

idrewuk

macrumors regular
Original poster
Aug 15, 2008
208
120
Thanks so much, really appreciate it. Live and learn!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.