2
I built a code to prevent my search tool from searching with the blank search field or with the default message that appears in value, I received a piece of code and when implementing an error that previously did not occur in layout, has a small part of the code that I do not have the knowledge of what it does and that before had not in the code and did not appear the error.
I have the following code:
<form name="produtosBuscaForm" method="get" action="http://busca.exemplo.com.br" onsubmit="return ajaxsearchsubmit(this)">
<!--!! <input type="hidden" name="Categoria" value="0" id="categoria"> !!-->
$&{<input type="hidden" name="view" value="(view)" />}
<div class="busca">
<div class="inputbusca">
<input type="text" name="w" maxlength="35" value="Digite a busca" onfocus="if(this.value == 'Digite a busca') { this.value = ''; }" onblur="if(value=='') value ='Digite a busca'"id="sli_search_1" autocomplete="off" style="font-family:Verdana, Geneva, sans-serif;font-style:italic;font-weight:lighter;font-size:12px;color:#999999;outline:none;">
</div>
<a href="javascript:return ajaxsearchsubmit(document.produtosBuscaForm);" class="ok"></a>
</div>
</form>
My doubt is regarding the following part:
<!--!! <input type="hidden" name="Categoria" value="0" id="categoria"> !!-->
$&{<input type="hidden" name="view" value="(view)" />}
The commented part OK, but what would be the command $&{ }
? I wonder if this part might be causing me the error?
From what I understand (as described on this blog in English),
$&
returns the last string returned by a regular expression. In this context, I don’t know if this is what might be causing the error, it may be easier to determine if you mount an example in jsFiddle.– dang
Tests if the input is empty or with default text, give some type of Alert and a false Return. It is no longer easy?
– dsantoro
What error does appear? I have an answer almost ready to send to you.
– felipekm
No error appears exactly, the search works only that on the screen appears the code "$&{ }" I did not understand why they created a commented input followed by another input (which I see the error in question) and a third in the sequence (which is what actually works) I received this code and I am implementing in our site but I do not understand why it was assembled this way
– CRAJ
Got it, this is wrong, just delete this $&command, because it should be in a <script> tag and not directly in html as there is.
– felipekm
I will remove and see if the features remain correct! I also thought it was wrong but was not going to remove without the certainty of being an error. Thank you
– CRAJ