This topic is locked

Minimum Search Length

11/7/2008 9:13:49 AM
PHPRunner General questions
F
Frink09 author

This is probably a very easy task to accomplish but I didn't see it in the forums or built into PHPRunner. How do you set a minimum search length of three or four characters? If someone types in "a" or "ab" they are instructed that they have to enter in a minimum of 'X' characters. I saw something related to this on the ASPrunner forum but not for PHP, any thoughts? Thank you in advance!

J
Jane 11/10/2008

Hi,
edit generated ..._list.php file for this purpose.

Find this line:

$xt->assign("searchbutton_attrs","onClick=\"java script: RunSearch('".$id."');\"");



and replace it with this one:

$xt->assign("searchbutton_attrs","onClick=\"java script: if (document.forms.frmSearch".$id.".SearchFor.value.length<4) { document.getElementById('ctlSearchFor').value=''; alert('Enter four characters or more'); } else RunSearch('".$id."');\"");

F
Frink09 author 11/11/2008

Thank you for the response however I'm unable to find that first string in the PHP file, I tried searching the entire site and the specific file. I'm running PHPRunner 4.2, is that why?

J
Jane 11/12/2008

Hi,
yes, this code works for PHPRunner 5.0 only.

In the PHPRunner 4.2 you can add JavaScript code in HTML mode on the Visual Editor tab directly.

F
Frink09 author 11/12/2008

How does this look?

<INPUT id=ctlSearchFor name=ctlSearchFor

{$search_searchfor} {if $useAJAX} autocomplete="off" onkeydown="return listenEvent(event,this,'ordinary');" onkeyup="searchSuggest(event,this,'ordinary');" {else} onkeydown="e=event; if(!e) e = window.event; if (e.keyCode != 13) return true; e.cancel = true; RunSearch(); return false;" {/if}> <INPUT class=button onclick="java script: if (document.forms.frmSearch".$id.".SearchFor.value.length<4) { document.getElementById('ctlSearchFor').value=''; alert('Enter four characters or more'); } else RunSearch('".$id."');\"");" type=button value=Search>

J
Jane 11/13/2008

Hi,
please check my changes:

<INPUT id=ctlSearchFor name=ctlSearchFor

{$search_searchfor} {if $useAJAX} autocomplete="off" onkeydown="return listenEvent(event,this,'ordinary');" onkeyup="searchSuggest(event,this,'ordinary');" {else} onkeydown="e=event; if(!e) e = window.event; if (e.keyCode != 13) return true; e.cancel = true; RunSearch(); return false;" {/if}>{literal}<INPUT class=button onclick="java script: if (document.forms.frmSearch".$id.".SearchFor.value.length<4) { document.getElementById('ctlSearchFor').value=''; alert('Enter four characters or more'); } else RunSearch('".$id."');\"");" type=button value=Search>{/literal}

F
Frink09 author 11/13/2008

Didn't work, I received this error message:
Smarty error: [in _Customer_list.htm line 48]: syntax error: unrecognized tag: document.getElementById('ctlSearchFor').value=''; alert('Enter four characters or more'); (Smarty_Compiler.class5.php, line 436)

J
Jane 11/14/2008

Hi,
please make sure you have applied my changes on the page.
If it doesn't help publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.