I'm building a form in PHP and I have a field that currently works fine like this:
<input type='text' name='Name' value='Name'/>
But I dont want the users to have to rub out the value manually so I did this:
<input type='text' name='Name' value='Name'
onblur="if(this.value==''){ this.value='Name'; this.style.color='#BBB';}"
onfocus="if(this.value=='Name'){ this.value=''; this.style.color='#000';}"
style="color:#BBB;" />
But obviously since this is in PHP and the form starts with $output="<form...
it didnt work and brought up errors because of the "
So I then created this:
<input type='text' name='Name' value='Name'
onblur='if(this.value==''){ this.value='Name'; this.style.color='#BBB';)'
onfocus='if(this.value=='Name'){ this.value=''; this.style.color='#000';}'
style='color:#BBB' />
Which doesn't through up errors, but simply doesn't work. I mean the form shows up correctly, but the value does not disappear with clicks. So I thought of changing the '
inside the onblur
and onfocus
to "
and this worked in html but brought up the same error as before in php. So what is the solution to this?