TinyPortal

Development => Support => Topic started by: ApplianceJunk on July 26, 2008, 02:58:06 AM

Title: What type of block should I use for this code?
Post by: ApplianceJunk on July 26, 2008, 02:58:06 AM
Using SMF 1.1.5 and TP v0.9.8

I'm using this code in a phpbox for the search box at the top of our site @ ApplianceJunk.com and it works great.

global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br />
<table>
<tr>
  <td align="center"><input type="text" name="search" value="" size="31" maxlength="100"></td>
<td><input type="image" src="http://www.appliancejunk.com/imgs/search.gif" alt="Search" width="20" height="16">
<input type="hidden" name="advanced" value="0" />
  </td>
</tr>
</table>

<table align="center">
<tr>
  <td style="font-family:Arial; font-size:10pt; color:#A7A7A7; padding:1; padding-left:15; padding-bottom:0;" height="5">Search ApplianceJunk.com</td>         
</tr>
</table>

</form><p></p>';



I edit the code by adding this

value="Search ApplianceJunk.com" onfocus="if
(this.value==this.defaultValue) this.value='';"


That put the "Search ApplianceJunk.com" in the text box and when you click the text box to type it removes it.

With that code added I end up with this.

global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br />
<table>
<tr>
  <td align="center"><input type="text" name="search" value="Search ApplianceJunk.com" onfocus="if
(this.value==this.defaultValue) this.value='';" size="31" maxlength="100" style="color:#A7A7A7"></td>
<td><input type="image" src="http://www.appliancejunk.com/imgs/search.gif" alt="Search" width="20" height="16">
<input type="hidden" name="advanced" value="0" />
  </td>
</tr>
</table>

</form><p></p>';


The last code seems to work fine in my editor, First Page 2006.

But when I put the code in a phpbox I get this error in the box.

QuoteParse error: syntax error, unexpected '<' in /home/applianc/public_html/forums/Sources/Load.php(1797) : eval()'d code(35) : eval()'d code on line 1

When I put the edited code in a scriptbox it looks like it's going to work, but the search button does not work.

Being the search button is php I can kind of see why, but I don't understand what I should do to get my code to work.

Seems I have a combination of php and something else with this code that I'm trying to add.

value="Search ApplianceJunk.com" onfocus="if
(this.value==this.defaultValue) this.value='';"


I have been working on this for about four hours and it's starting to make me  :uglystupid2:

Would love to hear some thoughts on my problem.

Thanks,
Title: Re: What type of block should I use for this code?
Post by: JPDeni on July 26, 2008, 03:07:33 AM
You have a problem with quotes. It should work if you change your code to


value="Search ApplianceJunk.com" onfocus="if
(this.value==this.defaultValue) this.value=\'\';"
Title: Re: What type of block should I use for this code?
Post by: ApplianceJunk on July 26, 2008, 04:18:17 AM
That works great!

It would have been many more hours before I would have got that one on my own.

Thank you,
AJ
Title: Re: What type of block should I use for this code?
Post by: JPDeni on July 26, 2008, 05:27:59 AM
Those are the hardest problems to find. I've gone hours with things like that myself.

Marking it solved.