Question on Code Error for a Search Box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
homesupplyguy
Forum Newbie
Posts: 1
Joined: Tue Aug 11, 2009 3:19 pm

Question on Code Error for a Search Box

Post 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Question on Code Error for a Search Box

Post 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?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Question on Code Error for a Search Box

Post by jackpf »

I see it in the top right corner :P
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Question on Code Error for a Search Box

Post by aceconcepts »

hahaha exactly - it's closer than you think eh 8O
Post Reply