87,910
社区成员
发帖
与我相关
我的任务
分享
你代码我测试没问题
后面有一部分是没用的代码 [quote=引用 7 楼 qq_39687238 的回复:] 有点长哦。。。。。。。。。
你代码我测试没问题
后面有一部分是没用的代码 [quote=引用 7 楼 qq_39687238 的回复:] 有点长哦。。。。。。。。。
后面有一部分是没用的代码 有点长哦。。。。。。。。。
有点长哦。。。。。。。。。 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript" src="js/jquery-1.7.2.min.js" ></script> </head> <style type="text/css"> *{margin:0;padding:0;list-style-type:none;} a,img{border:0;text-decoration:none;} body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";} .demo{width:620px;margin:40px auto 0 auto;} .sx,.zj{padding-bottom:10px;} .sx a{color:#000;line-height:22px;display:inline-block;width:50px;height:22px;margin-right:10px;border:1px solid #fff;text-align:center;padding-right:6px;} a.on{border:1px solid red;background:url(images/xx.jpg) no-repeat right top;} .sx span,.zj span{display:inline-block;line-height:22px;height:22px;color:#00F;font-size:14px;margin-right:10px;text-align:right;width:70px;} .zj a{color:#fff;line-height:22px;display:inline-block;width:100px;height:22px;margin-right:10px;border:1px solid #C00;text-align:center;background:url(images/xx2.jpg) no-repeat right top #C00;padding-right:10px;} .qcqb{width:70px;height:22px;line-height:22px;background:#FF0;color:#690;display:none;display:inline-block;text-align:center;border:1px solid #ccc;cursor:pointer;} </style> <body> <div class="demo"> <div class="sx"> <span>分类1:</span> <a onclick="testget(this.rel)" rel="1" class="sx_child" name="aaa" href="javascript:;">1111</a> <a onclick="testget(this.rel)" rel="2" class="sx_child" name="aaa" href="javascript:;">2222</a> <a onclick="testget(this.rel)" rel="3" class="sx_child" name="aaa" href="javascript:;">3333</a> <a onclick="testget(this.rel)" rel="4" class="sx_child" name="aaa" href="javascript:;">4444</a> </div> <div class="zj"> <span>删选结果:</span> <p class="qcqb">清除全部</p> </div> </div> <button onclick="test()">确定</button> <script type="text/javascript"> var str1; function testget (str) { alert(str); str1=str; alert(str1); } function test() { alert(str1); } </script> <script type="text/javascript"> </script> <script type="text/javascript" src="js/shanxuan.js"></script> <script type="text/javascript"> $('.sx').sx( { nuv:".zj",//筛选结果 zi:"sx_child",//所有筛选范围内的子类 qingchu:'.qcqb',//清除全部 over:'on'//选中状态样式名称 // var test = "...."; // 需要提交的变量 // document.getElementById("").value = test } ); </script> <script type="text/javascript"> var data=[ { "id": 1, "text": 1 }, { "id": 2, "text": 2 }, { "id": 3, "text": 3 }, { "id": 4, "text": 4 }] //例子1 //单选 $('#demo1').comboboxfilter({ url: '', scope: 'FilterQuery1', data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); $('#demo2').comboboxfilter({ url: '', scope: 'FilterQuery2', multiple: true, data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); $('#demo3').comboboxfilter({ url: '', : 'FilterQuery3', data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); $('#demo4').comboboxfilter({ url: '', scope: 'FilterQuery3', multiple: true, data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); $('#demo5').comboboxfilter({ url: '', scope: '', unlimitText:'全部', data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); $('#demo6').comboboxfilter({ url: '', scope: '', unlimitText:'全部', multiple: true, data:data, onChange:function(newValue){ $('#demo_value').val(newValue); } }); </script> </body> </html>
var str1= [];
function testget (str)
{
alert(str);
str1.psuh(STR);
alert(str1);
}
可能是你哪里弄错了,发下完整代码,或者试试我这个<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <title> 页面名称 </title> </head> <body> <input type="button" value="保存" onclick="saveStr('abc');" /> <input type="button" value="读取" onclick="loadStr();" /> <script type="text/javascript"> var str1; function saveStr(str) { str1 = str; } function loadStr() { alert(str1); } </script> </body> </html>
定义一个全局的数据,每次都存入值,不要定义局部的数组
- - [quote=引用 4 楼 qq_39687238 的回复:] [quote=引用 3 楼 showbo 的回复:] 感觉你函数调用顺序有问题,要是调用了testget先,test肯定可以获取到str的值,而不是undefined,最好发你代码全来,不要发什么截图,特别讨厌 是不是调用testget的控件是放在表单中的提交按钮,导致表单提交了刷新一次所以str又是undefined了 推荐学习资料 jqGrid一些疑难问题和解决方案 jqGrid中文API
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
</head>
<body>
<input type="button" value="保存" onclick="saveStr('abc');" />
<input type="button" value="读取" onclick="loadStr();" />
<script type="text/javascript">
var str1;
function saveStr(str) {
str1 = str;
}
function loadStr() {
alert(str1);
}
</script>
</body>
</html>
[quote=引用 3 楼 showbo 的回复:] 感觉你函数调用顺序有问题,要是调用了testget先,test肯定可以获取到str的值,而不是undefined,最好发你代码全来,不要发什么截图,特别讨厌 是不是调用testget的控件是放在表单中的提交按钮,导致表单提交了刷新一次所以str又是undefined了 推荐学习资料 jqGrid一些疑难问题和解决方案 jqGrid中文API
感觉你函数调用顺序有问题,要是调用了testget先,test肯定可以获取到str的值,而不是undefined,最好发你代码全来,不要发什么截图,特别讨厌 是不是调用testget的控件是放在表单中的提交按钮,导致表单提交了刷新一次所以str又是undefined了 推荐学习资料 jqGrid一些疑难问题和解决方案 jqGrid中文API