标题:
一段处理SELECT选择框联运的代码,自己花了三天写出
[打印本页]
作者:
admin
时间:
2011-11-3 09:19
标题:
一段处理SELECT选择框联运的代码,自己花了三天写出
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
});
function kk1(a){
var selectedValue =a;
$("#suppliers_id1").children("span").each(function(){
$(this).children().clone().replaceAll($(this));
});
if(parseInt(selectedValue) != 0){
$("#suppliers_id1").children("option[parentid!='" + selectedValue + "'][parentid1!='" + selectedValue + "'][parentid3!='" + selectedValue + "'][parentid5!='" + selectedValue + "'][parentid6!='" + selectedValue + "'][parentid4!='" + selectedValue + "'][value!='0']").each(function(){
$(this).wrap("<span style='display:none'></span>");
});
}
$("#suppliers_id3").children("span").each(function(){
$(this).children().clone().replaceAll($(this));
});
if(parseInt(selectedValue) != 0){
$("#suppliers_id3").children("option[parentid!='" + selectedValue + "'][parentid1!='" + selectedValue + "'][parentid3!='" + selectedValue + "'][parentid5!='" + selectedValue + "'][parentid6!='" + selectedValue + "'][parentid4!='" + selectedValue + "'][value!='0']").each(function(){
$(this).wrap("<span style='display:none'></span>");
});
}
$("#suppliers_id4").children("span").each(function(){
$(this).children().clone().replaceAll($(this));
});
if(parseInt(selectedValue) != 0){
$("#suppliers_id4").children("option[parentid!='" + selectedValue + "'][parentid1!='" + selectedValue + "'][parentid3!='" + selectedValue + "'][parentid5!='" + selectedValue + "'][parentid6!='" + selectedValue + "'][parentid4!='" + selectedValue + "'][value!='0']").each(function(){
$(this).wrap("<span style='display:none'></span>");
});
}
$("#suppliers_id5").children("span").each(function(){
$(this).children().clone().replaceAll($(this));
});
if(parseInt(selectedValue) != 0){
$("#suppliers_id5").children("option[parentid!='" + selectedValue + "'][parentid1!='" + selectedValue + "'][parentid3!='" + selectedValue + "'][parentid5!='" + selectedValue + "'][parentid6!='" + selectedValue + "'][parentid4!='" + selectedValue + "'][value!='0']").each(function(){
$(this).wrap("<span style='display:none'></span>");
});
}
$("#suppliers_id6").children("span").each(function(){
$(this).children().clone().replaceAll($(this));
});
if(parseInt(selectedValue) != 0){
$("#suppliers_id6").children("option[parentid!='" + selectedValue + "'][parentid1!='" + selectedValue + "'][parentid3!='" + selectedValue + "'][parentid5!='" + selectedValue + "'][parentid6!='" + selectedValue + "'][parentid4!='" + selectedValue + "'][value!='0']").each(function(){
$(this).wrap("<span style='display:none'></span>");
});
}
}
function kk3() {
$("#suppliers_id").val($(this).children("option:selected").attr("parentid"));
$("#suppliers_id").val($(this).children("option:selected").attr("parentid1"));
}
</script>
HTML代码
<select id="suppliers_id" name="suppliers_id" onchange="kk1(this.value)">
<!--<option value="0">{$lang.suppliers_no}</option> -->
<option value="0">请选择供货商</option>
{foreach from=$suppliers11 item=suppliers11goods key=i}
<option value="{$suppliers11goods.suppliers_id}" { if $suppliers11goods.suppliers_id==$goods.suppliers_id } selected="selected" {/if}>{$suppliers11goods.suppliers_name}</option>
{/foreach}
<!-- {html_options options=$suppliers_list_name selected=$goods.suppliers_id}
--> </select>
<input type="text" name="suppliers_goods_price" value="{$goods.suppliers_goods_price|escape}" style="display:none" size="9" />
<input type="text" name="suppliers_goods_discount" value="{$goods.suppliers_goods_discount|escape}" style="display:none" size="9" />
<input type="text" name="suppliers_goods_lowprice" value="{$goods.suppliers_goods_lowprice|escape}" style="display:none" size="9" />
<input type="checkbox" id="is_freight" name="is_freight" {if $goods.is_freight==1} checked="true" {/if} value="1" style="display:none" /><input type="checkbox" id="is_tax" name="is_tax" {if $goods.is_tax==1} checked="true" {/if} value="1" style="display:none" />
<input type="button" value="+" onclick="addsup(1)" class="button" style="display:none"/>
</td>
</tr>
{/if}
<tr id="suppliers_id16" >
<td class="label">所购商品1 :</td>
<td>
<select id="suppliers_id1" name="suppliers_id1" onchange="kk3();">
<!--<option value="0">{$lang.suppliers_no}</option> -->
<option value="0">请选择商品名称</option>
{foreach from=$goods11 item=goodsuppliers key=i}
<option value="{$goodsuppliers.goods_id}" {if $goodsuppliers.suppliers_id==''} parentid="0" {else} parentid="{$goodsuppliers.suppliers_id}" {/if} parentid1="{$goodsuppliers.suppliers_id1}" parentid3="{$goodsuppliers.suppliers_id3}" parentid4="{$goodsuppliers.suppliers_id4}" parentid5="{$goodsuppliers.suppliers_id5}" parentid6="{$goodsuppliers.suppliers_id6}" { if $goodsuppliers.goods_id==$goods.suppliers_id1 } selected="selected" {/if} >{$goodsuppliers.goods_name}</option>
{/foreach}
<!-- {html_options options=$in_suppliers_list_name selected=$goods.suppliers_id1} -->
</select>
欢迎光临 鸣蝉论坛 (http://cdtaobao.net/upload/bbs/)
Powered by Discuz! 7.0.0