Page 1 of 1

Question on Code Error for a Search Box

Posted: Tue Aug 11, 2009 3:29 pm
by homesupplyguy
Hi I'm new here, and trying to debug a new site I'm working on. Seems like this is a REALLY helpful forum - so maybe someone kind enough to tell me my error. The code is for a search box on an HTML/PHP site...and it's set up to have default text...and 'onclick', then it's supposed to remove the default text and let the user type their search.

However, dreamweaver is giving me huge 'Error' message, saying
<?> Invalid markup...Markup invalid because it contains a duplicate attribute.
<input...Remove the duplicate attribute

Here's the section...and I've bolded the part that Dreamweaver says has an error.
---------------
<form action="index.php" method="post"><span class="searchform">
<label></label>
</span>
<div align="right">

<input name="search" type="text" class="searchboxtext" id="search"
<?if ($search !=""){?>
value="<?=$search?>" onfocus="if(this.value == 'Style, Brand, Color, etc') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Style, Brand, Color, etc';}"
<?}else{?>
value="Style, Brand, Color, etc" onfocus="if(this.value == 'Style, Brand, Color, etc') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Style, Brand, Color, etc';}"
<?}?>
/>


<input type="image" src="<?=$root_http?>images/searchbutton.jpg" align="middle" /><span class="searchform"> </span></div>
</form>
-----------------

I would LOVE it if someone could help me learn what's wrong here, if you spot which attribute is duplicate...or how I can make the error go away while still doing on the 'on click' stuff. I'm trying to teach myself and some stuff is easy, but this one is tricky for me. Thank you so much.

Best,
Mike

Re: Question on Code Error for a Search Box

Posted: Tue Aug 11, 2009 4:16 pm
by aceconcepts
Try this:

Code: Select all

value="Search…" onclick="if(this.value=='Search…')this.value='';" onblur="if(this.value=='')this.value='Search…';"
Can anyone guess where this is from?

Re: Question on Code Error for a Search Box

Posted: Tue Aug 11, 2009 5:28 pm
by jackpf
I see it in the top right corner :P

Re: Question on Code Error for a Search Box

Posted: Tue Aug 11, 2009 7:01 pm
by aceconcepts
hahaha exactly - it's closer than you think eh 8O