Inhaltsverzeichnis
Heim
Backend-Entwicklung
PHP-Tutorial
javascript – So ändern Sie die dynamische Auswahl in ein UL-Navigationsformular. Bitten Sie um Führung.



javascript – So ändern Sie die dynamische Auswahl in ein UL-Navigationsformular. Bitten Sie um Führung.
Sep 11, 2016 am 11:34 AM
css
html
javascript
php
Sehen Sie sich den Code an.
<code> <!-- 大系列 --> <td style="visibility: hidden;">{$lang.big_series}<select name="big_cate_id" id="big_cate_id"> <option value="">{$lang.please_select}</option> {foreach from=$big_series item=big}<option value="{$big.sapval}" rel="{$big.cat_id}">{$big.cat_name}</option>{/foreach} </select> </td> </tr> <!-- 小系列 --> <!-- <td>{$lang.sub_series}<select name="sub_cate_id" id="sub_cate_id" onchange="searchGoods();"> <option value="">{$lang.please_select}</option> {foreach from=$sub_series item=sub}<option value="{$sub.sapval}" class="s{$sub.parent_id}">{$sub.cat_name}</option>{/foreach} </select> </td> --> <!-- 商品号or商品名 --> <tr> <td align="center"> <input type="text" name="keyword" size="15" placeholder="产品名(号)" style="height:19px;line-height:19px;" /> <input type="submit" value="搜索产品" class="button" /> </td> </tr> <tr> <td>{$lang.sub_series}<select name="sub_cate_id" id="sub_cate_id" onchange="searchGoods();" size="20"> {foreach from=$sub_series item=sub}<li value="{$sub.sapval}" class="s{$sub.parent_id}">{$sub.cat_name}</li>{/foreach} </select> </td> </tr> $(document).ready(function(){ $('#big_cate_id').change(function(){ var sapval = $(this).val(); var cat_id = 0; $(this).find('option').each(function(){ if($(this).attr('value') == sapval){ cat_id = $(this).attr('rel'); } }); $('#sub_cate_id').empty(); $('#sub_cate_id').append('<option value="">{$lang.please_select}</option>'); if(sapval == ''){ for(var i=0,len=subcate.length; i<len; i++){ $('#sub_cate_id').append("<option value='"+ subcate[i].sapval +"'>" + subcate[i].cat_name + "</option>"); } }else{ for(var i=0,len=subcate.length; i<len; i++){ if(subcate[i].parent_id == cat_id){ $('#sub_cate_id').append("<option value='"+ subcate[i].sapval +"'>" + subcate[i].cat_name + "</option>"); } } } }); }); {/literal} listTable.recordCount = {$record_count}; listTable.query = 'list'; listTable.pageCount = 1; {foreach from = $filter item = item key = key} listTable.filter.{$key} = '{$item}'; {/foreach} function searchGoods() { listTable.filter['big_cate_id'] = document.forms['searchForm'].elements['big_cate_id'].value; listTable.filter['sub_cate_id'] = document.forms['searchForm'].elements['sub_cate_id'].value; listTable.filter['keyword'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value); listTable.filter['src'] = '{$src}'; listTable.loadList(); } ![图片描述][1] </code>
Nach dem Login kopieren
Nach dem Login kopieren
Antwortinhalt:
Sehen Sie sich den Code an.
<code> <!-- 大系列 --> <td style="visibility: hidden;">{$lang.big_series}<select name="big_cate_id" id="big_cate_id"> <option value="">{$lang.please_select}</option> {foreach from=$big_series item=big}<option value="{$big.sapval}" rel="{$big.cat_id}">{$big.cat_name}</option>{/foreach} </select> </td> </tr> <!-- 小系列 --> <!-- <td>{$lang.sub_series}<select name="sub_cate_id" id="sub_cate_id" onchange="searchGoods();"> <option value="">{$lang.please_select}</option> {foreach from=$sub_series item=sub}<option value="{$sub.sapval}" class="s{$sub.parent_id}">{$sub.cat_name}</option>{/foreach} </select> </td> --> <!-- 商品号or商品名 --> <tr> <td align="center"> <input type="text" name="keyword" size="15" placeholder="产品名(号)" style="height:19px;line-height:19px;" /> <input type="submit" value="搜索产品" class="button" /> </td> </tr> <tr> <td>{$lang.sub_series}<select name="sub_cate_id" id="sub_cate_id" onchange="searchGoods();" size="20"> {foreach from=$sub_series item=sub}<li value="{$sub.sapval}" class="s{$sub.parent_id}">{$sub.cat_name}</li>{/foreach} </select> </td> </tr> $(document).ready(function(){ $('#big_cate_id').change(function(){ var sapval = $(this).val(); var cat_id = 0; $(this).find('option').each(function(){ if($(this).attr('value') == sapval){ cat_id = $(this).attr('rel'); } }); $('#sub_cate_id').empty(); $('#sub_cate_id').append('<option value="">{$lang.please_select}</option>'); if(sapval == ''){ for(var i=0,len=subcate.length; i<len; i++){ $('#sub_cate_id').append("<option value='"+ subcate[i].sapval +"'>" + subcate[i].cat_name + "</option>"); } }else{ for(var i=0,len=subcate.length; i<len; i++){ if(subcate[i].parent_id == cat_id){ $('#sub_cate_id').append("<option value='"+ subcate[i].sapval +"'>" + subcate[i].cat_name + "</option>"); } } } }); }); {/literal} listTable.recordCount = {$record_count}; listTable.query = 'list'; listTable.pageCount = 1; {foreach from = $filter item = item key = key} listTable.filter.{$key} = '{$item}'; {/foreach} function searchGoods() { listTable.filter['big_cate_id'] = document.forms['searchForm'].elements['big_cate_id'].value; listTable.filter['sub_cate_id'] = document.forms['searchForm'].elements['sub_cate_id'].value; listTable.filter['keyword'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value); listTable.filter['src'] = '{$src}'; listTable.loadList(); } ![图片描述][1] </code>
Nach dem Login kopieren
Nach dem Login kopieren
Das Select-Tag hat das Attribut size
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heißer Artikel
Repo: Wie man Teamkollegen wiederbelebt
3 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt
3 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
Wie lange dauert es, um Split Fiction zu schlagen?
3 Wochen vor
By DDD

Hot-Tools-Tags

Heißer Artikel
Repo: Wie man Teamkollegen wiederbelebt
3 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt
3 Wochen vor
By 尊渡假赌尊渡假赌尊渡假赌
Wie lange dauert es, um Split Fiction zu schlagen?
3 Wochen vor
By DDD

Heiße Artikel -Tags

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

PHP 8.4 Installations- und Upgrade-Anleitung für Ubuntu und Debian

So richten Sie Visual Studio-Code (VS-Code) für die PHP-Entwicklung ein
