jsp中带有checkbox的属性菜单需要用easyui组件来实现,代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CheckBox Tree - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="//themes/default/easyuicss">
<link rel="stylesheet" type="text/css" href="//themes/iconcss">
<link rel="stylesheet" type="text/css" href="/democss">
<script type="text/javascript" src="//jqueryminjs"></script>
<script type="text/javascript" src="//jqueryeasyuiminjs"></script>
</head>
<body>
<h2>CheckBox Tree</h2>
<p>Tree nodes with check boxes</p>
<div style="margin:20px 0;">
<a href="#" class="easyui-linkbutton" onclick="getChecked()">GetChecked</a>
</div>
<div style="margin:10px 0">
<input type="checkbox" checked onchange="$('#tt')tree({cascadeCheck:$(this)is(':checked')})">CascadeCheck
<input type="checkbox" onchange="$('#tt')tree({onlyLeafCheck:$(this)is(':checked')})">OnlyLeafCheck
</div>
<div class="easyui-panel" style="padding:5px">
<ul id="tt" class="easyui-tree" data-options="url:'tree_data1json',method:'get',animate:true,checkbox:true"></ul>
</div>
<script type="text/javascript">
function getChecked(){
var nodes = $('#tt')tree('getChecked');
var s = '';
for(var i=0; i<nodeslength; i++){
if (s != '') s += ',';
s += nodes[i]text;
}
alert(s);
}
</script>
</body>
</html>
运行效果:
写一个最简单的例子做参考吧 import javaawtBorderLayout;import javaawtContainer;
import javaawtDimension;import javaxswingJFrame;
import javaxswingJTable;
import javaxswingtableDefaultTableModel;public class JTableTest extends JFrame {
private JTable table;
private DefaultTableModel model;
private Object[] header={"1","2","3"};
private Object[][] data={{"sdf",new Integer(1),new Boolean(false)},{"abc",new Integer(2),new Boolean(true)}};
public JTableTest()
{
initComponent();
thissetMinimumSize(new Dimension(300,300));
thissetLocationRelativeTo(null);
thissetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
}
private void initComponent()
{
Container content=thisgetContentPane();
model=new DefaultTableModel(data,header){
public Class<> getColumnClass(int columnIndex) {
return getValueAt(0, columnIndex)getClass();
}
};
table=new JTable(model);
contentadd(tablegetTableHeader(),BorderLayoutNORTH);
contentadd(table);
}
public static void main(String[] args) {
new JTableTest()setVisible(true); }
}你的购买是一个链接,那么在链接上面传一个参数就行了,
<a href="purcharseGoodId=001"></a> //purcharse是自己定义的
要得到的话在servlet(如果用其他框架也一样)中用requestgetParameter("GoodId");得到参数值;
如果你的购买是一个按钮的话,把该行的goodId保存在按钮中就可以了:
<button onclick="documentforms[0]submit" name="GoodId" value="001">购买</button>
要得到goodid还是和上面一样,这样就不用每行写一个form了
如果要同时把好几个产品都放到购物车而且又要获得该行的ID推荐用第2个方法,第一个方法要写一段js,我js学得不好,希望对你有帮助
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)