日期:2014-05-19  浏览次数:20705 次

请教一个Checkbox 获得选中值Id的问题
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
  <title>添加销售报价</title>
  <script type="text/javascript">
 
//全选
function checkEvent(name,allCheckId){
var allCk=document.getElementById(allCheckId);
if(allCk.checked==true)
checkAll(name);
else
checkAllNo(name);
}

function checkAll(name){
var names=document.getElementsByName(name);
var len=names.length;
if(len>0){
var i=0;
for(i=0;i<len;i++){
names[i].checked=true;
}
}
}
//全不选

function checkAllNo(name){
var names=document.getElementsByName(name);
var len=names.length;
if(len>0){
var i=0;
for(i=0;i<len;i++)
names[i].checked=false;
}
}
//获得选中的值
function chbox(){
var inputs = document.getElementsByName('pName');
for(var i = 0; i<inputs.length; i++){
var obj = inputs[i];
alert(inputs[i].value);
if(obj.type == 'checkbox'){
if(obj.checkbox == true){
alert(obj.value);
}
}
}
}



//返回
function back(){
history.go(-1);
}

  </script>

  </head>
  
  <body>
  <h2 align="center">销售机会---->销售报价管理</h2>
  <s:form action="insertSubmit" namespace="/sellorder">
  <button onclick="javascript:findByIdFrominsert(document.forms[0],'<c:out value="${filterSalechanceId}"/>');">保存</button>
  <button onclick="javascript:findByIdFromlistType(document.forms[0],'<c:out value="${filterSalechanceId}"/>');">添加产品</button>
  <button onclick="javascript:findByIdFromlist(document.forms[0],'<c:out value="${filterSalechanceId}"/>');">竞争对手报价</button>
  <button onclick="javascript:fromQuote(document.forms[0],'<c:out value="${filterSalechanceId}"/>');">历史报价</button>
  <button onclick="back();">返回</button>
  <button onclick="chbox()">点击我查看选择哪些</button>
  <s:hidden id="filterSalechanceId" name="filterSalechanceId" value=""/>
  <s:hidden id="a" name="a" value=""/>
  <s:hidden name="filterProductId" id="filterProductId" value=""/>
  <s:hidden id="filterOfferDetailedId" name="filterOfferDetailedId" value=""/>
  <s:hidden id="filterQuotationId" name="filterQuotationId" value=""/>
  <s:hidden id="count" name="count" value=""/>
  <s:hidden id="c" name="c" value=""/>
<br/>
  <table align="center" border="1px">
  <tr>
<td><s:text name="编号"/></td>
<td><s:property value="salechanceId"/>&nbsp;</td>
<td><s:text name="机