日期:2014-05-17  浏览次数:20592 次

[新人求助]jsp页面,函数没起作用,也不知道怎么调。
小弟初学jsp,现在遇到下面一个问题:点击按钮不起作用,按钮上的字没变化,而且id为btn2的按钮也不起作用。求围观,求解答。


这是js函数:

function manage(obj){
var height=window.screen.availHeight
var width=window.screen.availWidth
height=(height-500)/2;
width=(width-600)/2;
var options = "height=300,width=550,left="+width+",top="+height+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no";

if(obj == "转交客服"){
var url="../sysmng/operation/zhuanjiao.jsp";
var newWin = window.open(url,"",options);
newWin.focus();
document.getElementById('btn1').value = "跟踪查看";
document.getElementById("td1").innerText="已转交";

}else{
var url="../sysmng/operation/genzhong.jsp";
var newWin = window.open(url,"",options);
newWin.focus();
}
}


这是html代码:

……
<td id="td1">未处理</td>
<td ><input type="button" id="btn1" onclick="manage(this.value)" value="转交客服"></td>

……
<td >已转交</td>
<td ><input type="button" id="btn2" onclick="manage(this.value)" value="跟踪查看"></td>

------解决方案--------------------
具体什么问题?是没转向相关jsp页面?还是js语法有问题?

var height=window.screen.availHeight
var width=window.screen.availWidth

这两句句尾怎么没;号呢。。
------解决方案--------------------
你先alert(obj)看看是否是转交客服,
在if分支里alert试试进到if逻辑里,
然后把
document.getElementById('btn1').value = "跟踪查看";
document.getElementById("td1").innerText="已转交";
放到if的最前两行,看是否能变字,
最后我估计是jsp的相对路径写错了。。。

------解决方案--------------------
页面应该没什么问题 你js 各行alert() 一下 看看 走到哪了,
用IE 打开该页面 ,看看IE左下角 有没有叹号,有叹号 点开看看什么错。
------解决方案--------------------
探讨
obj == "转交客服" 这样ok么? if (obj.equals("转交客服")) {...} 如何?

------解决方案--------------------
<td id="td1">未处理</td>
<td ><input type="button" id="btn1" onclick="manage('转交客服');" value="转交客服"></td>

<td >已转交</td>
<td ><input type="button" id="btn2" onclick="manage('跟踪查看');" value="跟踪查看"></td>
JScript code

function manage(obj){
alet(1);
var height=window.screen.availHeight;
var width=window.screen.availWidth;
height=(height-500)/2;
width=(width-600)/2;
var options = "height=300,width=550,left="+width+",top="+height+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no";

if(obj.equals=("转交客服")){
alert(2);
var url="../sysmng/operation/zhuanjiao.jsp";
var newWin = window.open(url,"",options);
newWin.focus();
document.getElementById('btn1').value = "跟踪查看";
document.getElementById("td1").innerText="已转交";

}else{
alert(3);
var url="../sysmng/operation/genzhong.jsp";
var newWin = window.open(url,"",options);
newWin.focus();
}
}

------解决方案--------------------
探讨
还有个问题就是:
因为我在var url="../sysmng/operation/zhuanjiao.jsp";这个jsp里有个确认与否的confirm,我想如果confirm()选择的是true后再改变按钮的值,如果选择的是false就不做改变,如何实现啊?