DA东
2014-09-17 13:49:08
完
js遍历tr取出下拉列表中的值,然后拼接数组。。。解决掉后追加牛币...
之前的效果是这样的..
z这是之前的效果...遍历tr如果复选框选中..那么拼接字符串...拼接的内容有id+dealNote
现在其中的一个复选按钮换成下拉框...
然后这次遍历tr的时候判断下拉列表...如果下拉列表有值择在原字符串上加上id+dealNote+下拉值..
按钮时候写的代码是这样的。。。。。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
function reachedOut() {
var reachArr = '';
var revokeArr = '';
$('table#datatable > tbody > tr').each(function(index,data){
var id = $(this).attr('id');
var txt = $(this).find('textarea:first').val();
//alert($(this).find("select").val())
$(this).find('div.btn-group-xs > button.btn-success').each(function(){
if ($(this).val()=='1'){
reachArr += id+'#['+txt+']'+'|';
}
if($(this).val()=='2'){
revokeArr += id+'#['+txt+']'+'|';
}
});
});
$('#reachedids').val(reachArr);
$('#revokeids').val(revokeArr);
$('form#clicked').attr('action','${pageContext.request.contextPath}/ident/updateReachedOut.do');
$('form#clicked').submit();
}
$('#datatable tbody tr button').click(function(){
if($(this).hasClass("btn-info")){
$(this).removeClass("btn-info");
$(this).addClass("btn-success");
$(this).siblings("button").each(function(idx, data){
$(this).removeClass("btn-success");
$(this).addClass("btn-info");
})
}else{
$(this).removeClass("btn-success");
$(this).addClass("btn-info");
}
});
function test_fontToRed(itemId) {
var id_tmp='item_'+itemId;
$('#'+id_tmp).css('color','#9f301d');
}
</script>
<style>
/* a:link {color: #000; text-decoration:none;} */
/* a:visited { color: #000;text-decoration:none;} */
/* a:hover {color: #bc2931; text-decoration:underline;}
a:active {color: #000;} */
</style>
<button type="button" class="btn btn-primary" onClick="reachedOut()">Submit</button>
<table id="datatable" class="table table-bordered">
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>Description</th>
<th>Gender</th>
<th Views onclick="sortCategroy()" id="categroy">Categroy</th>
<th Views onclick="sortVideos()" id="videos">Videos</th>
<th Views onclick="sortViews()" id="views">Views</th>
<th Views onclick="sortSubscribers()" id="subscribers">Subscribers</th>
<th Views onclick="sortPlatform()" id="platform">Platform</th>
<th>DealNote</th>
<th>DealStatus</th>
<th>Mark</th>
</tr>
</thead>
<tbody>
<c:forEach items="${userRepList}" var="item" varStatus="in">
<tr id="${item.id}" >
<td>${in.index+1}</td>
<td><a href="${item.url}" target="_blank" onClick="test_fontToRed('${item.id}')"><font id='item_${item.id}'>${item.name}</font></a></td>
<td>${item.description}</td>
<td>${item.gender}</td>
<td>${item.category}</td>
<td>${item.videos}</td>
<td>${item.views}</td>
<td>${item.subscribers}</td>
<td>${item.platform}</td>
<td><textarea name="dealnote" value="${item.dealNote}" style="width:100%;height:100%;">${item.dealNote}</textarea></td>
<td>${item.dealStatus}</td>
<td>
<div class="btn-group-xs btn-group-vertical">
<!-- <select name="way" value="1">
<option>Reached-out</option>
<option value="QQ">QQ</option>
<option value="微博">微博</option>
<option value="微信">微信</option>
</select> -->
<button type="button" class="btn btn-info" value="1">Reached-out</button>
<button type="button" class="btn btn-info" value="2">Revoke</button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<button type="button" class="btn btn-primary" onClick="reachedOut()">Submit</button>
求各位会的牛牛帮我改一下.....谢谢.....
评论
所有回答列表(2)
caoyue521 LV18
2014年9月17日
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
function reachedOut() {
var reachArr = '';
var revokeArr = '';
$('table#datatable > tbody > tr').each(function(index,data){
var id = $(this).attr('id');
var txt = $(this).find('textarea:first').val();
//alert($(this).find("select").val())
$(this).find('div.btn-group-xs > btn-group-vertical').each(function(){
if ($(this).find('select:first').val()=='QQ'){
reachArr += id+'#['+txt+']'+'QQ'+'|';
}
if($(this).find('select:first').val()=='微博'){
revokeArr += id+'#['+txt+']'+'微博'+'|';
}
if($(this).find('select:first').val()=='微信'){
revokeArr += id+'#['+txt+']'+'微信'+'|';
}
});
});
$('#reachedids').val(reachArr);
$('#revokeids').val(revokeArr);
$('form#clicked').attr('action','${pageContext.request.contextPath}/ident/updateReachedOut.do');
$('form#clicked').submit();
}
$('#datatable tbody tr button').click(function(){
if($(this).hasClass("btn-info")){
$(this).removeClass("btn-info");
$(this).addClass("btn-success");
$(this).siblings("button").each(function(idx, data){
$(this).removeClass("btn-success");
$(this).addClass("btn-info");
})
}else{
$(this).removeClass("btn-success");
$(this).addClass("btn-info");
}
});
function test_fontToRed(itemId) {
var id_tmp='item_'+itemId;
$('#'+id_tmp).css('color','#9f301d');
}
</script>
评论(2)
最佳答案
遇见, LV36
2014年9月18日
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--引入-JQUERY--->
<!--<script type="text/javascript" src="jquery-1.7.2.min.js">-->
<script type="text/javascript">
function test(){
var result = "";
$("#testTable select[name = 'way']").each(function(e){
result += this.value+",";
});
result = result.substring(0, result.length-1);
alert(result);
}
</script>
</head>
<body>
<table id="testTable">
<tr>
<td>FV</td>
</tr>
<tr>
<td>
<select name="way">
<option>Reached-out</option>
<option value="QQ">QQ</option>
<option value="微博">微博</option>
<option value="微信" selected>微信</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="way">
<option>Reached-out</option>
<option value="QQ" selected>QQ</option>
<option value="微博">微博</option>
<option value="微信">微信</option>
</select>
</td>
</tr>
</table>
<input type="button" id="testBtn" onclick="test()" value="test" />
</body>
</html>
是这样么
- 等 最代码怎么获取牛币啊?
- 完 谁来告诉我最代码上线的时间,答对者给5牛币,先来先得
- 等 牛友们,大家好,你们做程序员多久了?现在还好吗?
- 完 在微信打开的页面里进行app下载
- 等 最代码2014年欢乐聚声会
- 完 mysql如何查询表数据并且对3个字段降序的SQL?
- 完 最代码牛币机制改革
- 完 成功的在bae上使用了自定义运行环境 jetty+nginx的组合,大家对jetty+nginx优化有哪些心得?
- 完 进来分享一下各位牛牛是如何加入最代码大家庭的?
- 等 为什么java BufferedImage类处理大图直接抛出内存溢出的异常?
- 等 最代码是否开发手机app客户端?
- 完 java程序员学习哪些java的技术?java有哪些框架?都能做哪方面的开发?
- 等 php格式网页文件怎么运行?
- 等 Java volatile值获取的问题
- 等 前端vue,拦截了登录后台后,返回的token,requests拦截token,但是发送请求的时候,就出现跨越异常
- 等 大专本科计算机科班怎么找到Java工作?
- 等 eclipse怎么把三个java swing游戏项目合成一个项目?
- 完 伙伴们,大家都有什么好的解压方式么,分享一下~
- 完 三四线城市,6、7k,运维工作,索然无味,想去辞职上培训,各位牛牛有什么建议嘛
- 等 jsp页面输入中文变成问号
- 等 JPA在线上运行一段时间后报错Caused by: java.lang.IncompatibleClassChangeError: null
- 等 PHP 这个规则用preg_match_all怎么写
- 等 大佬们,有没有知道Alfresco如何配置LDAP登录呢?
- 等 php的install目录是框架带的吗?
相关问答
- 等 js这段脚本语法如何解释?
- 完 js如何实现二维数组各个对应位置相加的算法?
- 等 如何实现js弹出一个添加或修改的子窗口,然后提交刷新页面功能?
- 等 js如何将数组实现排列组合?
- 等 js中数字类型的字符串为什么不能转换为Number?
- 完 前端js点击每一行的删除图标删除行后保存怎么获取没有被隐藏的行?
- 等 js如何实现在一个图片上鼠标移动过去图片周围有光圈,在点击图片的时候有声音发出的特效?
- 完 js如何在文本框中输入5并且在下面出来五行呢?
- 等 js代码如何实现隐藏chrome浏览器的地址栏?
- 等 js怎么写提交表单的方法?
- 完 js怎么实现提交按钮后还是在当前页面?
- 完 如何理解js的这个语法?
最近浏览
代码男神2019 LV10
2019年3月4日
390330 LV1
2018年8月7日
qq921622105 LV8
2018年3月2日
bobo123 LV2
2017年12月12日
sowang LV9
2017年10月23日
bawang5021 LV1
2017年9月6日
zhengyu05 LV1
2017年5月3日
qwertyuio LV2
2017年4月13日
hand_com LV2
2017年3月29日
evygyw LV1
2016年12月15日






