<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Yss-add.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<link rel="stylesheet" href="js/default/easyui.css" type="text/css"></link>
<link rel="stylesheet" href="js/icon.css" type="text/css"></link>
</head>
<body>
选择供货商:<select id="se" onchange="bb()"></select>
<a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="add()">添加</a>
<table id="dg" class="easyui-datagrid" title="商品表"></table>
<form style="background-color:red;width:500;height:200">
<table id="table22">
<tr>
<td>编号</td>
<td>名称</td>
<td>价格</td>
</tr>
</table>
</form>
</body>
</html>
<script>
var url="";
$.ajax({
url:'xialai.action',
type:'post',
dataType:'json',
async:false,
success:function(data){
var Str="";
//alert(data[2])
for(i=0;i<data.length;i++){
Str+="<option value="+data[i].SHID+">"+data[i].SHNAME+"</option>";
}
$("#se").html(Str);
}
})
function bb(){
var aa=$('#se').val();
$('#dg').datagrid({
url:'car.action?shid='+aa,
//EnableHeaderVisualStyles:false,
//singleSelect:true,//只能单选
fitColumns:true,
columns:[[
{field:'CARGOID',title:'商品ID',width:100},
{field:'CARGONAME',title:'商品名称',width:100},
{field:'CARGOSUM',title:'商品数量',width:100,align:'right'},
]]
});
}
$(function(){
$("#se").trigger("change");
})
function zj(){
var a=parseInt($('#price').val());
var b=parseInt($('#sl').val());
var c=a*b;
$('#jg').val(c);
}
function add(){
//得到被选中行的数据
var item = $('#dg').datagrid('getSelections');
for(var i=0;i<item.length;i++){
Str+="<td><input value="+item[i].CARGOID+"></td>";
Str2+="<td><input value="+item[i].CARGONAME+"></td>";
Str3+="<td><input value="+item[i].CARGOSUM+"></td>";
var tr = document.createElement("tr");
tr.innerHTML = str+str2+str3;
}
}
</script>
insertCell 添加行,行.innerHTML=str
能写的详细点么 还是不怎么懂