我在 smarty 网站上工作,我正在使用下拉框、文本框等搜索网站。除了一个下拉框外,一切正常。我没有找到我要去的地方。在主页上,我有下拉框。当您选择某些内容并点击提交按钮时,下一个表单将打开,这里有相同的下拉框,因此它应该显示所选值(我们在主页上选择)。但这恰恰是没有发生的。在这里,我发布了我尝试过的两种形式的代码。请帮帮我。只有“cmbSidebarRegions”下拉框不工作,除了一切工作正常。只有“cmbSidebarRegions”值未在表单提交时显示为选中状态。
1) 这是一个主页
{block name=header}
<script type="text/javascript" src="{$smarty.const.PATH__JS}/ad.list.js"></script>
{/block}
<div id="QuickSearch" class="span-34 last prepend-1 prepend-top append-bottom">
<div class="span-50 prepend-1 last">
<form method="post" action="?module=main&page=ad&action=list">
<div id="search_home" style="margin-left: 28px;">
{assign var="keyword" value=""}
{if isset($Keyword)}
{assign var="keyword" value=$Keyword}
{/if}
<input type="text" id="txtKeyword" name="txtKeyword" placeholder="Enter Keywords...." value="{$keyword}" style="width:532px;"/>
</div>
<div class="search_location" style="margin-top:8px;">
<label style="margin-left:6px; margin-right:6px;">in</label>
{assign var="Location" value=""}
{assign var="LocationID" value="-1"}
{assign var="LocationType" value="-1"}
{assign var="CityID" value="-1"}
{if isset($ObjRegion)}
{assign var="Location" value=$ObjRegion->strRegion}
{assign var="LocationID" value=$ObjRegion->intID}
{assign var="LocationType" value="region"}
{/if}
{if isset($ObjCity)}
{assign var="Location" value=$ObjCity->strCity}
{assign var="LocationID" value=$ObjCity->objRegion->intID}
{assign var="LocationType" value="city"}
{assign var="CityID" value=$ObjCity->intID}
{/if}
<select id="cmbSidebarRegions" name="cmbSidebarRegions" class="append-bottom" style="width:190px">
<option value="-1" selected="selected">All Ireland</option>
{foreach from=$Regions item=ObjRegion key=id name=index}
<optgroup label="{$ObjRegion->strRegion}">
<option value="?module=main&page=ad&action=list&hdLocationType=region&hdLocationID={$ObjRegion->intID}">All Counties in {$ObjRegion->strRegion}</option>
{foreach from=$ObjRegion->GetCities() item=ObjCity key=id name=index}
{if isset($smarty.get.hdCityID) AND $smarty.get.hdCityID eq $ObjCity->intID}
<option value="?module=main&page=ad&action=list&hdLocationType=city&hdCityID={$ObjCity->intID}" selected="selected">{$ObjCity->strCity}</option>
{else}
<option value="?module=main&page=ad&action=list&hdLocationType=city&hdCityID={$ObjCity->intID}">{$ObjCity->strCity}</option>
{/if}
{/foreach}
</optgroup>
{/foreach}
</select>
<input type="hidden" id="hdLocationType" name="hdLocationType" value="{$LocationType}"/>
<input type="hidden" id="hdCityID" name="hdCityID" value="{$CityID}"/>
<input type="hidden" id="hdLocationID" name="hdLocationID" value="{$LocationID}"/>
<!--<input type="text" id="txtLocation" name="txtLocation" placeholder="Location" value="{$Location}"/>-->
<label style="margin-left:6px; margin-right:6px;">in</label>
{assign var="keywordLocation" value=""}
{if isset($KeywordLocation)}
{assign var="keywordLocation" value=$KeywordLocation}
{/if}
<input type="text" id="txtKeywordLocation" name="txtKeywordLocation" placeholder="Location/Area" value="{$keywordLocation}"/>
<label style="margin-left:6px; margin-right:6px;">in</label>
<span class="selectbox">{include file="blocks/selectbox.tpl" ID="cmbSection" Name="cmbSection" Data=$Sections OptionText="All Sections" label="strSection" value="intID"}</span>
<button type="submit">Search</button>
</div>
</form>
</div>
</div>
2) 这是第 2 页
{extends file="theme/master.tpl"}
{block name=lang}{config_load file="lang.en.conf" section="HOME"}{/block}
{block name=title}Ads Listing{/block}
{block name=header}
<script type="text/javascript" src="{$smarty.const.PATH__JS}/index.js"></script>
<script type="text/javascript" src="{$smarty.const.PATH__JS}/ad.list.js"></script>
{/block}
{block name=SideBar}
{include file="components/side.bar.tpl"}
{/block}
{block name=content}
<div class="span-36 last">
<div id="QuickSearch" class="span-34 last prepend-1 prepend-top">
<div class="span-50 prepend-1 last">
<div id="search_home" style="margin-left: 28px;">
{assign var="keyword" value=""}
{if isset($Keyword)}
{assign var="keyword" value=$Keyword}
{/if}
<input type="text" id="txtKeyword" name="txtKeyword" placeholder="Enter Keywords...." value="{$keyword}" style="width:509px;"/>
</div>
<div id="search_home" style="margin-left: 28px;">
{assign var="advertiser" value=""}
{if isset($Advertiser)}
{assign var="advertiser" value=$Advertiser}
{/if}
<input type="hidden" id="txtAdvertiser" name="txtAdvertiser" placeholder="Enter advertiser ID...." value="{$advertiser}" style="width:509px;"/>
</div>
<div class="search_location" style="margin-top:8px;">
<label style="margin-left:6px; margin-right:6px;">in</label>
<select id="cmbSidebarRegions" name="cmbSidebarRegions" class="append-bottom" style="width:161px">
<option value="-1" selected="selected">All Ireland</option>
{foreach from=$Regions item=ObjRegion key=id name=index}
<optgroup label="{$ObjRegion->strRegion}">
<option value="?module=main&page=ad&action=list&hdLocationType=region&hdLocationID={$ObjRegion->intID}">All Counties in {$ObjRegion->strRegion}</option>
{foreach from=$ObjRegion->GetCities() item=ObjCity key=id name=index}
{if isset($smarty.get.hdCityID) AND $smarty.get.hdCityID eq $ObjCity->intID}
<option value="?module=main&page=ad&action=list&hdLocationType=city&hdCityID={$ObjCity->intID}" selected="selected">{$ObjCity->strCity}</option>
{else}
<option value="?module=main&page=ad&action=list&hdLocationType=city&hdCityID={$ObjCity->intID}">{$ObjCity->strCity}</option>
{/if}
{/foreach}
</optgroup>
{/foreach}
</select>
<input type="hidden" id="hdLocationType" name="hdLocationType" value="{$LocationType}"/>
<input type="hidden" id="hdCityID" name="hdCityID" value="{$CityID}"/>
<input type="hidden" id="hdLocationID" name="hdLocationID" value="{$LocationID}"/>
<label style="margin-left:6px; margin-right:6px;">in</label>
{assign var="keywordLocation" value=""}
{if isset($KeywordLocation)}
{assign var="keywordLocation" value=$KeywordLocation}
{/if}
<input type="text" id="txtKeywordLocation" name="txtKeywordLocation" placeholder="Location/Area" value="{$keywordLocation}"/>
<label style="margin-left:6px; margin-right:6px;">in</label>
{assign var="SectionID" value=-1}
{if isset($Section)}
{assign var="SectionID" value="{$Section->intID}"}
{assign var="valsect" value="{$Section->strSection}"}
{/if}
{assign var="SubSectionID" value=-1}
{if isset($SubSection)}
{assign var="SectionID" value="{$SubSection->objSection->intID}"}
{assign var="SubSectionID" value="{$SubSection->intID}"}
{assign var="valsubsect" value="{$SubSection->strSubSection}"}
{/if}
<input type="hidden" id="hdSectionID" name="hdSectionID" value="{$SectionID}"/>
<input type="hidden" id="hdSubSectionID" name="hdSubSectionID" value="{$SubSectionID}"/>
<span class="selectbox">
<select id="cmbSectionGroup" name="cmbSectionGroup" style="width:150px">
<option value="-1">All Sections</option>
{foreach from=$arrSections item=Section}
<optgroup label="{$Section->strSection}">
<option value="section_{$Section->intID}">All Subsections in {$Section->strSection}</option>
{foreach from=$Section->arrSubSections item=SubSection}
<option value="{$SubSection->intID}">{$SubSection->strSubSection}</option>
{/foreach}
</optgroup>
{/foreach}
</select>
</span>
</div>
</div>
<div class="span-32 prepend-1 prepend-top">
<hr/>
</div>
<div class="span-32 prepend-1 last prepend-top-xxx">
<a id="btnSearchOptions" class="ss_sprite ss_bullet_toggle_plus" onclick="ShowSearchOptions()">Show More Search Options</a>
<div id="pnlAdvancedSearch" class="hide span-32 prepend-1 last prepend-top-xxx">
</div>
</div>
<div class="span-32 align-right prepend-top-x">
<button onclick="NextPageAds(1)" style="width:90px;cursor:pointer">Search</button>
<button onclick="Reset()" style="width:90px;cursor:pointer">Reset</button>
</div>
</div>
</div>
<div id="midlink">
<div class="left">
</div>
<div class="right">
<input type="button" value="Send me web feeds for this category" onclick="window.location = '?module=main&page=webfeeds&action=Subscribe'"/>
</div>
</div>
<div class="span-36 last">
<div id="pnlAds" class="span-34 last prepend-1 append-1 prepend-top append-bottom">
</div>
</div>
{/block}