如何把select下拉框的值传到id中实现代码?是不是很多用户们都被这个问题所困扰过,那么接下来我们就跟爱站小编一起去看看把select下拉框的值传到id中实现方法。
完整的代码如下:
HTML code:
复制代码
代码如下:
<!–
EOT;
if($step==1){
print <<
<!–
EOT;
$total_all=0;
$jinbi_all=0;
foreach($listdb AS $name=>$array){
$total=0;
$jinbi=0;
print <<<EOT
–>
-
全选
- 商品
- 返积分
- 数量
- 单价
- 总价
<!–
EOT;
foreach($array AS $rs){ $
rs[picurl]=$rs[picurl]?$rs[picurl]:”$webd[www_url]/images/default/nopic.jpg”;
$rs[picurl]=tempdir($rs[picurl]);
@extract($db->get_one(“SELECT content FROM {$_pre}content_$rs[mid] WHERE id=$rs[id]”));
$content=preg_replace(‘/<([^/is’,””,$content); //把HTML代码过滤掉
$content=preg_replace(‘/ | | /is’,””,$content); //把多余的空格去除掉 $content= get_word($content,100);
$total+=$rs[price2];
$total_all+=$rs[price2];
$jinbi+=$rs[jinbi2];
$jinbi_all+=$rs[jinbi2];
print <<<EOT
–>
-
$rs[title]
$rs[content]
- 0分
- {$rs[num]}
- {$rs[price]}元
- {$rs[price2]}元
<!–
EOT;
}print <<<EOT
–>
运送方式:
<!–
EOT;
if($rs[youfei]==”1″){print <<<EOT
–>
快递:10元 EMS:20元 平邮:50元
<!–
function changenum(price,type,id,uid){
price=parseFloat(price);
num = parseInt($(“#numid”+id).val());
if(type==1){ //增加
num++; }
else if(type==-1){ //减少
num–; }
else if(type==0){ //删除
num=0 }
if(type!=0 && num==0){
alert(‘数量不能小于1,若不想购买,请选择删除’);
num=1; }
$(“#numid”+id).val(num);
$(“#showid”+id).html(changeTwoDecimal(String(num*price))); obj=$(“.shows”+uid);
thispice = 0;
for(i=0;i<obj.size();i++){
thispice+=parseFloat(obj.eq(i).html()); }
$(“#total”+uid).html(thispice); if(type==0){
$.get(“join.php?type=setcookie&cid=”+id+”&num=”+0); $(“#tr”+id).hide(); }else{
$.get(“join.php?type=setcookie&cid=”+id+”&num=”+num+”&”+Math.random()); } obj2 = $(“.totalprice”);
if(obj2.size()>1){ thispice = 0; for(i=0;i<obj2.size();i++){
thispice+=parseFloat(obj2.eq(i).html()); }
$(“#total_all”).html(thispice); } }
function changeTwoDecimal(x){
var f_x = parseFloat(x);
if(isNaN(f_x)){
alert(‘function:changeTwoDecimal->parameter error’);
return false; }
var f_x = Math.round(x*100)/100; return f_x; }
function Add(m,id){ document.getElementById(id).innerHTML = parseInt(document.getElementById(id).getAttribute(“total”)+parseInt(m)) //–>
<!–
EOT; }
print <<<EOT
–>
店铺商品合计:
(含运费) $total元
卖家:{$rs[username]}
给卖家留言:
<!–
EOT; }print <<<EOT
–>
<!–
EOT;
if(count($listdb)>1){
print <<<EOT
–>
$total_all元
<!– EOT; }
print <<<EOT
–>
实付款:
<!–
EOT;
if(count($listdb)>1){
print <<<EOT
–>
$total_ll元
<!–
EOT; }
else{print <<<EOT
–>
$total元
<!–
EOT;
}print <<<EOT
–>
{$address_selects}
<!–
EOT;
if($job==’edit’){print <<<EOT
–>
<!–
$(document).ready(function(){
$(“#othermore”).show();$(“#dobutton”).hide();
});
//–>
删除
<!–
EOT;
}print <<<EOT
–>
<!–
function chooseAddress(selObj){
value = selObj.options[selObj.selectedIndex].value;
if(value==’-1′){
ifHideMoreTr(false); }
else{ ifHideMoreTr(true);
}
}
function ifHideMoreTr(type){
var arr = [“username”,”phone”,”mobphone”,”email”,”qq”,”postcode”,”address” ];
$(“#othermore input”).each(function (i){
if(jQuery.inArray(this.name.replace(/postdb\[order_([\w]+)\]/, “$1”),arr)!=-1){
obj=$(this).parent().parent();
if(type==true){
obj.hide()
}else{ obj.show()
}
}
});
}
$(document).ready(function(){
sObj = $(“#choose_Address”);
if(sObj.get(0).options.length==1||”$job”==”edit”){
sObj.parent().parent().hide
ifHideMoreTr(false);
}
else{ ifHideMoreTr(true);
}
});
//–>
<!–
EOT;
} print <<<EOT
–>
<!–
EOT;
?>
–>
想要的效果是:
当我选择ems20运费时,在运送方式中点击下拉框中的运费时那么就用 店铺合计总价+ 20元 当我点击平邮50元时,店铺合计总价+ 50元.
我说的要二个地方显示,是因为他如果存在二个不同的商家的商品时,会有二个商家合起来的总价和 商家商品本身的总价。
解决方法如下:
复制代码
代码如下:
快递:10元 EMS:20元 平邮:50元
对name=”postdb[youfei]“属性进行操作,在action中设置名为postdb[youfei]的参数,即:private String postdb[youfei],然后生成get/set方法,就可以取到值了!
上文就是小编介绍把select下拉框的值传到id中实现方法,其实方法还有很多很多,这里就不一一列举出来了,还有这里的代码可能不全面,有问题的话大家可以留言交流。