这个页面上有多个 select框 里面选择不通的产品 选择后在后面的单价栏目 显示相应的价格 请问怎么写?
解决方案 »
- 请问该怎么遍历json格式的arrayList?
- 请教一下,(function(){})()是什么意思啊?
- 如何使用javascript使得在某些控件的区域内鼠标滚轮的滚动不引起页面滚动?
- 求一个删除行的方法
- 如何交换两个<tr>标签里面的内容(求一个javascript函数)
- javascipt怎么访问另外一个网页上的数据
- 这段js代码怎么在jsp页面里实现啊
- How to highlight some text in an iframe by script?
- 请问大哥,怎么能跳过网页中弹出的网络密码的对话框,我直接传参数进去,不用当时输入。
- javascript的小问题……
- 二维数组如何替换其中的某一个元素?
- 为什么我的js语句用不了
$(this).closest("tr").find(".单价栏目元素的class").text($(this).val());
});
<table width="100%" >
<tr>
<th width="18%">项目</th>
<th width="30%">名称</th>
<th width="12%">单价</th>
<th width="18%">数量</th>
<th width="">价格</th>
</tr>
<!--{eval $depot_class = DB::fetch_all("SELECT * FROM %t Where pid=%d and class_on=%d and shop_on=%d ORDER BY displayorder ",array('geyu_depot_class',2,1,1));}-->
<!--{loop $depot_class $value}-->
<tr id="list{$value[id]}">
<td>{$value['name']}</td>
<td>
<select name="class_name" class="main_select" onChange="changeCollege()" >
<option value=""></option>
<!--{eval $shop = DB::fetch_all("SELECT * FROM %t Where class_id=%d ORDER BY displayorder",array('geyu_depot_shop_Monitor',$value[id]));}-->
<!--{loop $shop $value}-->
<option value="{$value[money]}">{$value[name]}</option>
<!--{/loop}-->
</select>
</td>
<td>
<div name="moeny"></div>
</td>
<td><input name="danj" type="text" name="" id="" value="1" /></td>
<td><span id="overt"></span></td>
</tr>
<!--{/loop}-->
</table>
<script type="text/javascript">
function changeCollege(){
//提取商品名称 name
var class_name=document.getElementsByName("class_name");
//提取价格名称 name
var moeny=document.getElementsByName("moeny");
// 循环商品名称
for(var i=0;i<class_name.length;i++){
//商品名称的选择事件
class_name[i].onclick=function(){
//打印价格到网页
console.log(this.value);
// moeny[i].innerHTML = 000;
}
}
}
</script>
div元素没有name属性,需要用class获取
<div class="moeny"></div>var moeny=document.getElementsByClassName("moeny");在事件内使用外面的循环变量时需要用闭包保存每次循环的值
for(var i=0;i<class_name.length;i++){
(function(i){
class_name[i].onclick=function(){
moeny[i].innerHTML = this.value;
}
})(i);
}
是不是 不能用onChange 事件