joebarker99 Posted May 9, 2008 Share Posted May 9, 2008 I'd like to edit this search page so that the search form requires a minimum number of characters in order to submit. Can someone create a code that I can add to this page? I've included the code of my 'search_links.tpl' page and my 'search.php' page. Thanks. search_links.tpl: <div class="containertable"> <h2>{$smarty.const.LA_SEARCH}</h2> <p class="headline">{$smarty.const.LA_SEARCH_DESCR}</p> <p> </p> <table border="0" width="100%" cellspacing="0" cellpadding="10"> <tr> <td width="100%"> <form action="search.php" name="itemForm" id="itemForm" method="get"> <script language="javascript"> xajax_myFunction('{$reg_2_value}'); xajax_myFunction('{$reg_3_value}'); </script> <input name="do_search" type="hidden" value="Search" /> <table cellspacing="3" border="0"> <tr> <td><span style="text">{$smarty.const.LA_SEARCH}</span> </td> <td><input id="searchword" name="searchword" size="25" class="txt" value="{$searchword}" /></td> <tr> <tr> <tr> <tr> </tr> {if $set_region==1} <tr> <td><span style="text">{$smarty.const.LA_REGION}</span></td> <td valign="top"> <select id="reg_1" name="reg_1" onChange='xajax_myFunction(reg_1.value)' class='regionselect'> {$reg_1_options} </select> <p><div id="DropDown2"></div></p> <p><div id="DropDown3"></div></p> </td> </tr> {/if} {foreach item=e from=$extra_fields_array} {if $e.q_include_search==1} {if $e.q_catdescr} <tr><td colspan="2"> <b>{$e.q_catdescr}</b><hr style="color:black;" width="50%" align="left"> </td></tr> {/if} <tr> <td valign="top">{$e.q_question} </td> <td valign="top"> {if $e.q_type=="t"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="{$e.q_size}" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="{$e.q_size}" value="{$e.q_value_to}" /> {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="p"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="4" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="4" value="{$e.q_value_to}" /> {$set_currency_text} {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="d"} <textarea cols="{$e.q_size}" rows="{$e.q_size_2}" name="e_{$e.q_field}">{$e.q_value}</textarea> {elseif $e.q_type=="c"} {foreach item=opt from=$e.options} <input type="checkbox" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {elseif $e.q_type=="s"} <select name="e_{$e.q_field}" class="txt"> <option value=''>--</option> {foreach item=opt from=$e.options} <option value="{$opt.value}" {if $opt.selected_value} selected{/if}>{$opt.text|escape}</option> {/foreach} </select> {elseif $e.q_type=="r"} {foreach item=opt from=$e.options} <input type="radio" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {/if} </td> </tr> {/if} {/foreach} <tr> <td colspan="2"><input type="submit" class="button" name="do_search" value="{$smarty.const.LA_SEARCH2}" /> <input type="submit" class="button" name="reset" value="Reset" /> </td> </tr> </table> </form> {if $hide!=1} <table cellspacing="0" class="box" style="clear:both;"> <tr> <th width="25%">{$CATEGORY_URL} {$smarty.const.CATEGORY}</a> {$image_cat}</th> <th width="35%">{$AD_URL} {$smarty.const.TITLE}</a></a> {$image_title}</th> {foreach item=extra from=$EXTRA_CAPTION_ARRAY} <th>{$extra.url}{$extra.caption|truncate:15:"...":true}</a> {$extra.sort_img}</th> {/foreach} <th width="10%">{$DATE_URL} {$smarty.const.DATE_ADDED}</a> {$image_date}</th> <th width="10%">{$PICTURE_URL} {$smarty.const.PICTURE_TEXT}</a> {$image_picture}</th> </tr> {if $NUM_ADS > 0} {foreach item=ad from=$ads} {if $ad.NB is even by 1} <tr class="alt"> {else} <tr> {/if} <td class="category">{$ad.CATEGORYNAME}</td> <td class="pointer"><a href="{$ad.LINK}"> {if $ad.SPECIAL}<b>{/if}{$ad.TITLE}{if $ad.SPECIAL}</b>{/if}</a></td> {foreach item=extraval from=$ad.EXTRA_VALUES} <td>{$extraval|truncate:20:"...":true}</td> {/foreach} <td>{$ad.REGDATE}</td> <td>{$ad.IMAGEYESNO}</td></tr> {/foreach} {else} <tr><td colspan=2><b>{$smarty.const.LA_NORESULTS}</b></td></tr> <tr><td colspan=5><br />Either the person you noticed has not submitted a post yet or you inserted the JNY-Code incorrectly. If you noticed this other person in a smaller town within a metropolitan area you may want to search using a JNY-Code with the smaller town's name and also search using a JNY-Code with the metropolitan city's name. For example, if you noticed this other person in Whittier, CA (located within the Los Angeles metropolitan area) on June 15, 2007 you may want to search using the JNY-Code: 06152007WHITTIERCA and, if that turns up no results try searching with the JNY-Code: 06152007LOSANGELESCA<br /><br /></td></tr> {/if} <tr> <td colspan="6" align="center"> {if $prev_url} <a href="{$prev_url}" class="button">< {$smarty.const.PREVIOUS_ADS} {$NUM_PER_PAGE}</a> {else} {/if} {if $next_url} <a href="{$next_url}" class="button">{$smarty.const.NEXT_ADS} {$NUM_PER_PAGE} ></a> {else} {/if} </td></tr></table> {/if} </td></tr></table> {literal} <script language="javascript" type="text/javascript"> <!-- content=document.getElementById("searchword"); if( content != null ){content.focus();} --> </script> {/literal} </div> search.php: <? $lUseAjax=1; $pagename=LA_SEARCH; include_once("header_inc.php"); $searchpage=1; $catid_search = getParamInt("catid_search",""); $lDoNotCreateTemplate=1; $tplList=new TplLoad; if (getParam("reset","")) redirect("search.php"); $lSearchWordTpl=getParam("searchword",""); $tplList->assign("set_region","$set_region"); $tplList->assign("searchword",$lSearchWordTpl); $tplList->assign("catlist",getCategoriesDD(getParamInt("catid_search",""),"")); $tplList->assign("set_currency_text","$set_currency_text"); $lExtraAdd=""; // Check if we have a category id to search in if($catid_search>0) { if (!$_REQUEST["catid_search"]=="%%") { $result_1 = q ("select cat_tpl from $cat_tbl where cat_id = ".round($_REQUEST["catid_search"])); $rad=mysql_fetch_array($result_1); $cattpl_cat = $rad["cat_tpl"]; } } $result_1 = q ("select cat_tpl from $cat_tbl where cat_id = '$catid_search'"); $row_cat = mysql_fetch_array($result_1); $cat_tpl = $row_cat["cat_tpl"]; /* Extra fields handling START */ $lFieldArray=getExtraFiltered($cat_tpl,"","",$set_language); if (is_array($lFieldArray)) { foreach ($lFieldArray as $lKey => $lValue) { if ($lValue["q_question"]) $lFieldArray[$lKey]["q_question"]=(constant($lValue["q_question"])); if ($lValue["q_catdescr"]) $lFieldArray[$lKey]["q_catdescr"]=(constant($lValue["q_catdescr"])); } } $lJoinedInputArray=array_merge($_POST,$_GET); /* Special code to fix so that intervals (from-to) can be performed */ foreach ($lJoinedInputArray as $key => $value) { //echo "$key - $value<br>"; if (ereg("from",$key)) { $key=ereg_replace("e_","",$key); $key=ereg_replace("_from","",$key); $lFieldArray["$key"]["q_value_from"]=$value; } elseif (ereg("to",$key)) { $key=ereg_replace("e_","",$key); $key=ereg_replace("_to","",$key); $lFieldArray["$key"]["q_value_to"]=$value; } } $tplList->assign("extra_fields_array",$lFieldArray); // Add question to template if (is_array($lFieldArray)) { $lReturnResultArray=ExtraFieldsInputOperations($lFieldArray); $lInsertArray=$lReturnResultArray[0]; // Contains data to be inserted to extra $errorMsg=$lReturnResultArray[1]; // Contains error messages } /* Extra fields handling FINISH */ if (count($lLevelArray)==3) { $lReg3Selected=$lLevelArray[1]["reg_id"]; $lReg3Father=$lLevelArray[1]["reg_father"] . "_"; $lReg2Selected=$lLevelArray[2]["reg_id"]; $lReg2Father=$lLevelArray[2]["reg_father"]; $lReg1Selected=$lLevelArray[3]["reg_id"]; } else if (count($lLevelArray)==2) { $lReg2Selected=$lLevelArray[1]["reg_id"]; $lReg2Father=$lLevelArray[1]["reg_father"]; } $lReg2Father=getParam("reg_1",$lReg2Father); $lReg2Selected=getParam("reg_2",$lReg2Selected); if ($lReg2Father && $lReg2Selected!="") $lReg2String=$lReg2Father . "|" . $lReg2Selected; else $lReg2String=$lReg2Father; $lReg3Father=getParam("reg_2",$lReg3Father); $lReg3Selected=getParam("reg_3",$lReg3Selected); if ($lReg3Father && $lReg3Selected!="") $lReg3String=$lReg3Father . "|" . $lReg3Selected; else $lReg3String=$lReg3Father; $tplList->assign("reg_2_value",$lReg2String); $tplList->assign("reg_3_value",$lReg3String); $tplList->assign("options",getRegionTree(0,0,$lSelected)); $lRegOptions="<option value=''>".LA_REGION_CHOOSE_FIRST."</option>"; $lRegOptions.=getRegionsForOneLevel(0,getParam("reg_1",$lReg1Selected),""); $tplList->assign("reg_1_options",$lRegOptions); if (getParam("do_search","") || getParam("searchword","")!="") require("links.php"); else { $tplList->assign("hide",1); $tplList->display("search_links.tpl"); } include_once("footer_inc.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/ Share on other sites More sharing options...
The Little Guy Posted May 9, 2008 Share Posted May 9, 2008 you could use javascript function minLen(){ var str = document.getElementById('search').value; if(str.length > 3){ document.myForm.submit(); } } <form action="search.php" method="get" name="myForm"> <input type="text" name="search" id="search" /> <input type="button" onclick="minLen()" value="Search" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537082 Share on other sites More sharing options...
joebarker99 Posted May 10, 2008 Author Share Posted May 10, 2008 I tried to copy and paste the first code into the search_links.tpl page and the second code into the search.php page. I'm not sure if that's what I was supposed to do but it didn't work for me. As you can probably tell, I'm very new to this. If I am supposed to copy and paste this code onto these pages could you please tell exactly where I should paste it? Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537228 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Both go into the template. Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537229 Share on other sites More sharing options...
joebarker99 Posted May 10, 2008 Author Share Posted May 10, 2008 Ok, I inserted both sets of code into the search_links.tpl page (lines 27-37) so that it now looks like the code below. But now when I try to use the search I get this error: "Fatal error: Smarty error: [in search_links.tpl line 33]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 580) in /home/content/j/u/s/justnoti/html/admin/libs/Smarty.class.php on line 1088" I've also included, at the bottom of the page, lines 567-581 of the Smarty_Compiler.class.php file and lines 1079-1089 of the Smarty.class.php file in case you need that to understand the error. Thanks for your help. Search_links.tpl: <div class="containertable"> <h2>{$smarty.const.LA_SEARCH}</h2> <p class="headline">{$smarty.const.LA_SEARCH_DESCR}</p> <p> </p> <table border="0" width="100%" cellspacing="0" cellpadding="10"> <tr> <td width="100%"> <form action="search.php" name="itemForm" id="itemForm" method="get"> <script language="javascript"> xajax_myFunction('{$reg_2_value}'); xajax_myFunction('{$reg_3_value}'); </script> <input name="do_search" type="hidden" value="Search" /> <table cellspacing="3" border="0"> <tr> <td><span style="text">{$smarty.const.LA_SEARCH}</span> </td> <td><input id="searchword" name="searchword" size="25" class="txt" value="{$searchword}" /></td> <tr> <tr> <tr> <tr> </tr> function minLen(){ var str = document.getElementById('search').value; if(str.length > 3){ document.myForm.submit(); } } <form action="search.php" method="get" name="myForm"> <input type="text" name="search" id="search" /> <input type="button" onclick="minLen()" value="Search" /> </form> {if $set_region==1} <tr> <td><span style="text">{$smarty.const.LA_REGION}</span></td> <td valign="top"> <select id="reg_1" name="reg_1" onChange='xajax_myFunction(reg_1.value)' class='regionselect'> {$reg_1_options} </select> <p><div id="DropDown2"></div></p> <p><div id="DropDown3"></div></p> </td> </tr> {/if} {foreach item=e from=$extra_fields_array} {if $e.q_include_search==1} {if $e.q_catdescr} <tr><td colspan="2"> <b>{$e.q_catdescr}</b><hr style="color:black;" width="50%" align="left"> </td></tr> {/if} <tr> <td valign="top">{$e.q_question} </td> <td valign="top"> {if $e.q_type=="t"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="{$e.q_size}" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="{$e.q_size}" value="{$e.q_value_to}" /> {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="p"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="4" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="4" value="{$e.q_value_to}" /> {$set_currency_text} {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="d"} <textarea cols="{$e.q_size}" rows="{$e.q_size_2}" name="e_{$e.q_field}">{$e.q_value}</textarea> {elseif $e.q_type=="c"} {foreach item=opt from=$e.options} <input type="checkbox" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {elseif $e.q_type=="s"} <select name="e_{$e.q_field}" class="txt"> <option value=''>--</option> {foreach item=opt from=$e.options} <option value="{$opt.value}" {if $opt.selected_value} selected{/if}>{$opt.text|escape}</option> {/foreach} </select> {elseif $e.q_type=="r"} {foreach item=opt from=$e.options} <input type="radio" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {/if} </td> </tr> {/if} {/foreach} <tr> <td colspan="2"><input type="submit" class="button" name="do_search" value="{$smarty.const.LA_SEARCH2}" /> <input type="submit" class="button" name="reset" value="Reset" /> </td> </tr> </table> </form> {if $hide!=1} <table cellspacing="0" class="box" style="clear:both;"> <tr> <th width="25%">{$CATEGORY_URL} {$smarty.const.CATEGORY}</a> {$image_cat}</th> <th width="35%">{$AD_URL} {$smarty.const.TITLE}</a></a> {$image_title}</th> {foreach item=extra from=$EXTRA_CAPTION_ARRAY} <th>{$extra.url}{$extra.caption|truncate:15:"...":true}</a> {$extra.sort_img}</th> {/foreach} <th width="10%">{$DATE_URL} {$smarty.const.DATE_ADDED}</a> {$image_date}</th> <th width="10%">{$PICTURE_URL} {$smarty.const.PICTURE_TEXT}</a> {$image_picture}</th> </tr> {if $NUM_ADS > 0} {foreach item=ad from=$ads} {if $ad.NB is even by 1} <tr class="alt"> {else} <tr> {/if} <td class="category">{$ad.CATEGORYNAME}</td> <td class="pointer"><a href="{$ad.LINK}"> {if $ad.SPECIAL}<b>{/if}{$ad.TITLE}{if $ad.SPECIAL}</b>{/if}</a></td> {foreach item=extraval from=$ad.EXTRA_VALUES} <td>{$extraval|truncate:20:"...":true}</td> {/foreach} <td>{$ad.REGDATE}</td> <td>{$ad.IMAGEYESNO}</td></tr> {/foreach} {else} <tr><td colspan=2><b>{$smarty.const.LA_NORESULTS}</b></td></tr> <tr><td colspan=5><br />Either the person you noticed has not submitted a post yet or you inserted the JNY-Code incorrectly. If you noticed this other person in a smaller town within a metropolitan area you may want to search using a JNY-Code with the smaller town's name and also search using a JNY-Code with the metropolitan city's name. For example, if you noticed this other person in Whittier, CA (located within the Los Angeles metropolitan area) on June 15, 2007 you may want to search using the JNY-Code: 06152007WHITTIERCA and, if that turns up no results try searching with the JNY-Code: 06152007LOSANGELESCA<br /><br /></td></tr> {/if} <tr> <td colspan="6" align="center"> {if $prev_url} <a href="{$prev_url}" class="button">< {$smarty.const.PREVIOUS_ADS} {$NUM_PER_PAGE}</a> {else} {/if} {if $next_url} <a href="{$next_url}" class="button">{$smarty.const.NEXT_ADS} {$NUM_PER_PAGE} ></a> {else} {/if} </td></tr></table> {/if} </td></tr></table> {literal} <script language="javascript" type="text/javascript"> <!-- content=document.getElementById("searchword"); if( content != null ){content.focus();} --> </script> {/literal} </div> Smarty_Compiler.class.php (lines 567-581): break; case 'insert': return $this->_compile_insert_tag($tag_args); default: if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) { return $output; } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) { return $output; } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) { return $output; } else { $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__); } Smarty.class.php (lines 1079-1089): /** * trigger Smarty error * * @param string $error_msg * @param integer $error_type */ function trigger_error($error_msg, $error_type = E_USER_WARNING) { if (file_exists("admin/config/opt_inc.php")) trigger_error("Smarty error: $error_msg", $error_type); } Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537259 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Enclose the function code in {literal}{/literal} tags. =) Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537264 Share on other sites More sharing options...
joebarker99 Posted May 10, 2008 Author Share Posted May 10, 2008 I've enclosed the function code in {literal}{/literal} tags but it only results in the function code being displayed in text form on the search page and doesn't do anything about requiring a minimum number of characters to use the search form. I realize I may be doing this incorrectly. Here's the code with the function code enclosed in the {literal}{/literal} tags (starting with line 27). Please let me know if I'm doing this incorrectly and what I should do to correct it. <div class="containertable"> <h2>{$smarty.const.LA_SEARCH}</h2> <p class="headline">{$smarty.const.LA_SEARCH_DESCR}</p> <p> </p> <table border="0" width="100%" cellspacing="0" cellpadding="10"> <tr> <td width="100%"> <form action="search.php" name="itemForm" id="itemForm" method="get"> <script language="javascript"> xajax_myFunction('{$reg_2_value}'); xajax_myFunction('{$reg_3_value}'); </script> <input name="do_search" type="hidden" value="Search" /> <table cellspacing="3" border="0"> <tr> <td><span style="text">{$smarty.const.LA_SEARCH}</span> </td> <td><input id="searchword" name="searchword" size="25" class="txt" value="{$searchword}" /></td> <tr> <tr> <tr> <tr> </tr> {literal}function minLen(){ var str = document.getElementById('search').value; if(str.length > 3){ document.myForm.submit(); } }{/literal} <form action="search.php" method="get" name="myForm"> <input type="text" name="search" id="search" /> <input type="button" onclick="minLen()" value="Search" /> </form> {if $set_region==1} <tr> <td><span style="text">{$smarty.const.LA_REGION}</span></td> <td valign="top"> <select id="reg_1" name="reg_1" onChange='xajax_myFunction(reg_1.value)' class='regionselect'> {$reg_1_options} </select> <p><div id="DropDown2"></div></p> <p><div id="DropDown3"></div></p> </td> </tr> {/if} {foreach item=e from=$extra_fields_array} {if $e.q_include_search==1} {if $e.q_catdescr} <tr><td colspan="2"> <b>{$e.q_catdescr}</b><hr style="color:black;" width="50%" align="left"> </td></tr> {/if} <tr> <td valign="top">{$e.q_question} </td> <td valign="top"> {if $e.q_type=="t"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="{$e.q_size}" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="{$e.q_size}" value="{$e.q_value_to}" /> {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="p"} {if $e.q_between==1} {$smarty.const.LA_BETWEEN} <input type="text" name="e_{$e.q_field}_from" size="4" value="{$e.q_value_from}" /> {$smarty.const.LA_AND} <input type="text" name="e_{$e.q_field}_to" size="4" value="{$e.q_value_to}" /> {$set_currency_text} {else} <input type="text" name="e_{$e.q_field}" size="{$e.q_size}" value="{$e.q_value}" /> {/if} {elseif $e.q_type=="d"} <textarea cols="{$e.q_size}" rows="{$e.q_size_2}" name="e_{$e.q_field}">{$e.q_value}</textarea> {elseif $e.q_type=="c"} {foreach item=opt from=$e.options} <input type="checkbox" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {elseif $e.q_type=="s"} <select name="e_{$e.q_field}" class="txt"> <option value=''>--</option> {foreach item=opt from=$e.options} <option value="{$opt.value}" {if $opt.selected_value} selected{/if}>{$opt.text|escape}</option> {/foreach} </select> {elseif $e.q_type=="r"} {foreach item=opt from=$e.options} <input type="radio" name="e_{$e.q_field}[]" id="{$e.q_field}" value="{$opt.value}" {if $opt.selected_value} checked{/if}> {$opt.text} <br /> {/foreach} {/if} </td> </tr> {/if} {/foreach} <tr> <td colspan="2"><input type="submit" class="button" name="do_search" value="{$smarty.const.LA_SEARCH2}" /> <input type="submit" class="button" name="reset" value="Reset" /> </td> </tr> </table> </form> {if $hide!=1} <table cellspacing="0" class="box" style="clear:both;"> <tr> <th width="25%">{$CATEGORY_URL} {$smarty.const.CATEGORY}</a> {$image_cat}</th> <th width="35%">{$AD_URL} {$smarty.const.TITLE}</a></a> {$image_title}</th> {foreach item=extra from=$EXTRA_CAPTION_ARRAY} <th>{$extra.url}{$extra.caption|truncate:15:"...":true}</a> {$extra.sort_img}</th> {/foreach} <th width="10%">{$DATE_URL} {$smarty.const.DATE_ADDED}</a> {$image_date}</th> <th width="10%">{$PICTURE_URL} {$smarty.const.PICTURE_TEXT}</a> {$image_picture}</th> </tr> {if $NUM_ADS > 0} {foreach item=ad from=$ads} {if $ad.NB is even by 1} <tr class="alt"> {else} <tr> {/if} <td class="category">{$ad.CATEGORYNAME}</td> <td class="pointer"><a href="{$ad.LINK}"> {if $ad.SPECIAL}<b>{/if}{$ad.TITLE}{if $ad.SPECIAL}</b>{/if}</a></td> {foreach item=extraval from=$ad.EXTRA_VALUES} <td>{$extraval|truncate:20:"...":true}</td> {/foreach} <td>{$ad.REGDATE}</td> <td>{$ad.IMAGEYESNO}</td></tr> {/foreach} {else} <tr><td colspan=2><b>{$smarty.const.LA_NORESULTS}</b></td></tr> <tr><td colspan=5><br />Either the person you noticed has not submitted a post yet or you inserted the JNY-Code incorrectly. If you noticed this other person in a smaller town within a metropolitan area you may want to search using a JNY-Code with the smaller town's name and also search using a JNY-Code with the metropolitan city's name. For example, if you noticed this other person in Whittier, CA (located within the Los Angeles metropolitan area) on June 15, 2007 you may want to search using the JNY-Code: 06152007WHITTIERCA and, if that turns up no results try searching with the JNY-Code: 06152007LOSANGELESCA<br /><br /></td></tr> {/if} <tr> <td colspan="6" align="center"> {if $prev_url} <a href="{$prev_url}" class="button">< {$smarty.const.PREVIOUS_ADS} {$NUM_PER_PAGE}</a> {else} {/if} {if $next_url} <a href="{$next_url}" class="button">{$smarty.const.NEXT_ADS} {$NUM_PER_PAGE} ></a> {else} {/if} </td></tr></table> {/if} </td></tr></table> {literal} <script language="javascript" type="text/javascript"> <!-- content=document.getElementById("searchword"); if( content != null ){content.focus();} --> </script> {/literal} </div> Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537279 Share on other sites More sharing options...
DeanWhitehouse Posted May 10, 2008 Share Posted May 10, 2008 if's it JS shouldn't it be enclosed in script tags? <script></script> (there should be more stuff in the tags like language, someone might be able to help there) Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537280 Share on other sites More sharing options...
The Little Guy Posted May 10, 2008 Share Posted May 10, 2008 Something simular to this (copy and paste bits and pieces NOT ALL OF IT!!): <p> </p> <script type="text/javascript"> function minLen(){ var str = document.getElementById('search').value; if(str.length > 3){ document.itemForm.submit(); } } </script> <table border="0" width="100%" cellspacing="0" cellpadding="10"> <form action="search.php" name="itemForm" id="itemForm" method="get"> <!-- MORE HTML HERE --> <input type="button" class="button" onclick="minLen();" name="do_search" value="{$smarty.const.LA_SEARCH2}" /> Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537306 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 You need html <script> tags inside of your Smarty {literal}'s. Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-537307 Share on other sites More sharing options...
joebarker99 Posted May 14, 2008 Author Share Posted May 14, 2008 You need html <script> tags inside of your Smarty {literal}'s. I tried that too. Couldn't get it to work. Can anyone out there create a code for this? Quote Link to comment https://forums.phpfreaks.com/topic/104926-minimum-of-characters-to-use-search-form/#findComment-540583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.