如何制作级联的选择列表表单来过滤内容

时间:2013-05-02 13:52:53

标签: php jquery html list select

我试图创建一个搜索表单,有多个可选选项,如品牌,型号,最小和最大年份,气体类型,新的,使用的和其他很少的。我以多个下拉列表的形式创建了搜索框,其中包含适当的值和多个复选框。

我想询问有关如何制作我创建的搜索框的建议,以过滤我的内容(适用于用户在搜索框中选择的参数),这些内容将以classfieds添加的形式显示。我很遗憾,价值观以我的母语呈现,但您应该明白这一点。

以下是选择列表和复选框的代码。非常感谢所有答案。

<?PHP
@ini_set("display_errors", 1);//the error handler is added later in FormProc
error_reporting(E_ALL & ~((defined('E_STRICT')?E_STRICT:0)|E_NOTICE));

require_once(dirname(__FILE__)."/includes/Iskanje_vozil-lib.php");
$formproc_obj =  new SFM_FormProcessor('Iskanje_vozil');
$formproc_obj->initTimeZone('default');
$formproc_obj->setFormID('9**66280-5820-**4b-b3**-1005ab*******');
$formproc_obj->setFormKey('d**41784-8b8c-**ca-a8**-771b54******');
$formproc_obj->setLocale('sl-SI','d.M.yyyy');
$formproc_obj->setEmailFormatHTML(true);
$formproc_obj->EnableLogging(false);
$formproc_obj->SetDebugMode(false);
$formproc_obj->setIsInstalled(true);
$formproc_obj->SetPrintPreviewPage(sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_print_preview_file.txt"));
$formproc_obj->SetSingleBoxErrorDisplay(true);
$formproc_obj->setFormPage(0,sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_form_page_0.txt"));
$formproc_obj->AddElementInfo('Izberite_model','db_loadedlist','');
$formproc_obj->AddElementInfo('Izberite_znamko','db_loadedlist','');
$formproc_obj->AddElementInfo('Cena_Od','db_loadedlist','');
$formproc_obj->AddElementInfo('Cena_Do','db_loadedlist','');
$formproc_obj->AddElementInfo('PrvaRegistracija_Do','db_loadedlist','');
$formproc_obj->AddElementInfo('PrvaRegistracija_Od','db_loadedlist','');
$formproc_obj->AddElementInfo('SteviloKilometrov_Do','db_loadedlist','');
$formproc_obj->AddElementInfo('tip_goriva','db_loadedlist','');
$formproc_obj->AddElementInfo('novotestnorabljeno','chk_group','');
$formproc_obj->setFormDBLogin('myurl','myusername','mypass','mydatabasename');
$formproc_obj->SetHiddenInputTrapVarName('t**e7b62**de0b6******');
$list_handler =  new FM_ListHandler();
$list_handler->AddList('Izberite_model',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_Izberite_model.txt"),true);
$list_handler->AddList('Izberite_znamko',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_Izberite_znamko.txt"),false);
$list_handler->AddList('Cena_Od',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_Cena_Od.txt"),false);
$list_handler->AddList('Cena_Do',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_Cena_Do.txt"),false);
$list_handler->AddList('PrvaRegistracija_Do',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_PrvaRegistracija_Do.txt"),false);
$list_handler->AddList('PrvaRegistracija_Od',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_PrvaRegistracija_Od.txt"),false);
$list_handler->AddList('SteviloKilometrov_Do',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_SteviloKilometrov_Do.txt"),false);
$list_handler->AddList('tip_goriva',sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_list_tip_goriva.txt"),false);
formproc_obj->addModule($list_handler);

$page_renderer =  new FM_FormPageDisplayModule();
$formproc_obj->addModule($page_renderer);



$tupage =  new FM_ThankYouPage(sfm_readfile(dirname(__FILE__)."/templ/Iskanje_vozil_thank_u.txt"));
$formproc_obj->addModule($tupage);

$formproc_obj->ProcessForm();
?>

另一部分是txt文件形式:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
   <head >
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
          <title >Form Page: Iskanje_vozil</title>
      <script src='scripts/jquery-1.7.2.min.js' type='text/javascript'></script>
      <script src='scripts/jquery.sim.casclist.js' type='text/javascript'></script>
      <script src='scripts/jquery.sim.dynlist.js' type='text/javascript'></script>
      <script src='scripts/jquery.sim.utils.js' type='text/javascript'></script>
      <link rel='stylesheet' type='text/css' href='style/Iskanje_vozil.css?r=%sfm_css_rand%'/>
   </head>
   <body id='sfm_Iskanje_vozil_body'>
      <form id='Iskanje_vozil' class='sfm_form' method='post' action='%sfm_self_script%' accept-charset='UTF-8'>
         <div id='Iskanje_vozil_errorloc' class='error_strings' style='width:300px;text-align:left'>%sfm_error_display_loc%</div>
         <div id='Iskanje_vozil_outer_div' class='form_outer_div' style='width:300px;height:400px'>
            <div style='position:relative' id='Iskanje_vozil_inner_div'>
               <input type='hidden' name='sfm_form_submitted' value='yes'/>
               <input type='hidden' name='%_sfm_form_id_iput_var_%' value='%_sfm_form_id_iput_value_%'/>
               <input type='text' name='t73e7b62d9de0b68c13fe' id='t73e7b62d9de0b68c13fe'/>
               <div id='label_container'>
                  <div id='label'>Znamka vozila:<br /></div>
               </div>
               <div id='label1_container'>
                  <div id='label1'>Model vozila:</div>
               </div>
               <div id='Izberite_model_container'>
                  <select name='Izberite_model' id='Izberite_model' size='1'></select>
               </div>
               <div id='Izberite_znamko_container'>
                  <select name='Izberite_znamko' id='Izberite_znamko' size='1'></select>
               </div>
               <div id='label2_container'>
                  <div id='label2'>Cena od:</div>
               </div>
               <div id='label3_container'>
                  <div id='label3'>do:</div>
               </div>
               <div id='Cena_Od_container'>
                  <select name='Cena_Od' id='Cena_Od' size='1'></select>
               </div>
               <div id='Cena_Do_container'>
                  <select name='Cena_Do' id='Cena_Do' size='1'></select>
               </div>
               <div id='label5_container'>
                  <div id='label5'>do:</div>
               </div>
               <div id='label4_container'>
                  <div id='label4'>Letnik 1.registracije od:</div>
               </div>
               <div id='PrvaRegistracija_Do_container'>
                  <select name='PrvaRegistracija_Do' id='PrvaRegistracija_Do' size='1'></select>
               </div>
               <div id='PrvaRegistracija_Od_container'>
                  <select name='PrvaRegistracija_Od' id='PrvaRegistracija_Od' size='1'></select>
               </div>
               <div id='label7_container'>
                  <div id='label7'>Tip goriva:</div>
               </div>
               <div id='label6_container'>
                  <div id='label6'>Kilometrov do:</div>
               </div>
               <div id='SteviloKilometrov_Do_container'>
                  <select name='SteviloKilometrov_Do' id='SteviloKilometrov_Do' size='1'></select>
               </div>
               <div id='tip_goriva_container'>
                  <select name='tip_goriva' id='tip_goriva' size='1'></select>
               </div>
               <div class='element_label' id='novotestnorabljeno_0_container'><input type='checkbox' name='novotestnorabljeno[]' id='novotestnorabljeno_item_0' value='Novo' %f22f8affb0591c19f05ab413a0826002%/><label for='novotestnorabljeno_item_0' class='element_label' id='novotestnorabljeno_item_0_label'>Novo</label></div>
               <div class='element_label' id='novotestnorabljeno_1_container'><input type='checkbox' name='novotestnorabljeno[]' id='novotestnorabljeno_item_1' value='Rabljeno' tabindex='1' %1b2d17f8b964bdd04eaa4cca7004d736%/><label for='novotestnorabljeno_item_1' class='element_label' id='novotestnorabljeno_item_1_label'>Rabljeno</label></div>
               <div class='element_label' id='novotestnorabljeno_2_container'><input type='checkbox' name='novotestnorabljeno[]' id='novotestnorabljeno_item_2' value='Testno' tabindex='2' %7d7b87b361311f4af3d17dc49ae9109f%/><label for='novotestnorabljeno_item_2' class='element_label' id='novotestnorabljeno_item_2_label'>Testno</label></div>
               <div id='Reset_container'>
                  <input type='button' name='Reset' value='Ponastavi iskanje' onclick='sfm_clear_form(&#039;form#Iskanje_vozil&#039;)' id='Reset'/>
               </div>
               <div id='Reset1_container'>
                  <input type='button' name='Reset1' value='Išči!' onclick='sfm_clear_form(&#039;form#Iskanje_vozil&#039;)' id='Reset1'/>
               </div>
            </div>
         </div>

      </form>
      <script type='text/javascript'>
// <![CDATA[
$(function()
{
   $('#Iskanje_vozil #Izberite_model').cascList({url:'%sfm_self_script%',params:{sfm_getlist:'Izberite_model'},parent:'Izberite_znamko',selected_val:'%Izberite_model%',parent_val:'%Izberite_znamko%'});
   $('#Iskanje_vozil #Izberite_znamko').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'Izberite_znamko'},selected_val:'%Izberite_znamko%'});
   $('#Iskanje_vozil #Cena_Od').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'Cena_Od'},selected_val:'%Cena_Od%'});
   $('#Iskanje_vozil #Cena_Do').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'Cena_Do'},selected_val:'%Cena_Do%'});
   $('#Iskanje_vozil #PrvaRegistracija_Do').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'PrvaRegistracija_Do'},selected_val:'%PrvaRegistracija_Do%'});
   $('#Iskanje_vozil #PrvaRegistracija_Od').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'PrvaRegistracija_Od'},selected_val:'%PrvaRegistracija_Od%'});
   $('#Iskanje_vozil #SteviloKilometrov_Do').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'SteviloKilometrov_Do'},selected_val:'%SteviloKilometrov_Do%'});
   $('#Iskanje_vozil #tip_goriva').dynList({url:'%sfm_self_script%',params:{sfm_getlist:'tip_goriva'},selected_val:'%tip_goriva%'});
});

// ]]>
      </script>
   </body>

如前所述,像选择列表和复选框这样的ID会在某种程度上充当值,并会以适当的方式过滤我的内容...非常感谢所有人。

0 个答案:

没有答案