RT, 我的页面里有表头表体 当用户选择进入表体时要先判断 表头的内容是不是已经 保存.下面是我的把页面分成表头表体的代码
<script language="javascript">function enterJob(id){
if(id==0){
if(document.getElementById("b").style.display=="block")
{
document.getElementById("b").style.display="none";
}
if(document.getElementById("b").style.display=="none")
{
document.getElementById("a").style.display="block";
}
}
if(id==1){
if(document.getElementById("a").style.display=="block")
{
document.getElementById("a").style.display="none";
}
if(document.getElementById("a").style.display=="none")
{
document.getElementById("b").style.display="block";
}
}
}
</ script ><body><table width="25%" cellspacing="0" cellpadding="0" class=httable01>
<tr>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(0)"><font
style="font-size:13px;font-family:黑体">作业单表头</font> </span>
</td>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(1)"><font
style="font-size:13px;font-family:黑体">作业单表体</font> </span>
</td>
</tr>
</table>
</body>
<script language="javascript">function enterJob(id){
if(id==0){
if(document.getElementById("b").style.display=="block")
{
document.getElementById("b").style.display="none";
}
if(document.getElementById("b").style.display=="none")
{
document.getElementById("a").style.display="block";
}
}
if(id==1){
if(document.getElementById("a").style.display=="block")
{
document.getElementById("a").style.display="none";
}
if(document.getElementById("a").style.display=="none")
{
document.getElementById("b").style.display="block";
}
}
}
</ script ><body><table width="25%" cellspacing="0" cellpadding="0" class=httable01>
<tr>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(0)"><font
style="font-size:13px;font-family:黑体">作业单表头</font> </span>
</td>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(1)"><font
style="font-size:13px;font-family:黑体">作业单表体</font> </span>
</td>
</tr>
</table>
</body>
解决方案 »
- 怎样用JS关闭当前页面???
- 光标跳转的问题
- 求助:jquery 处理多个同名input赋值的问题
- 谁能提供一份jquery validate remote和J2EE结合的实例
- jquery中如何把一个checkbox是否选中存到cookies里,然后在JS文件里取自己保存的状态。
- 如何通过js控制上下箭头(如:up,down)的使用?
- 请问:如何在浏览器中右键点击不同的对象时,弹出不同的右键菜单?
- 大家好,我又有问题向大家请教了,请帮助,谢谢
- 请问有办法可以获得播放结束的动作吗?
- 菜鸟一问:如何用js实现鼠标a.hover那样的效果?
- 正则匹配(URL重新)
- window.functionName = new Function() 有什么特别吗?
function save()
{
var myform = document.getElementById("InspectionWorkForm");
if(myform != null && document.getElementById("checkNo").value!=""){
var r = confirm("确认保存吗");
if(r){
uri = "../InspectionWork.do?method=save"
}else{
return false;
}
uri=encodeURI(uri);
myform.action=uri;
myform.submit();
var bj =document.getElementById("checkNo")
}
} 在保存里做标记的话该怎么办??
if(r){
uri = "../InspectionWork.do?method=save"
//保存后改变状态
}
<script language="javascript">
var all=0;------------------------------------------------------
保存时赋予全局变量一个新值
function save()
{
var myform = document.getElementById("InspectionWorkForm");
if(myform != null && document.getElementById("checkNo").value!=""){
var r = confirm("确认保存吗");
if(r){
uri = "../InspectionWork.do?method=save"
//给全局变量一个新值 all++;
}else{
return false;
}
uri=encodeURI(uri);
myform.action=uri;
myform.submit(); }
}
------------------------------------------------------------
当进去表体时 判断all的值 如果是0弹出提示,1就正常进入function enterJob(id){
//进入表头
if(id==0){
if(document.getElementById("b").style.display=="block")
{
document.getElementById("b").style.display="none";
}
if(document.getElementById("b").style.display=="none")
{
document.getElementById("a").style.display="block";
}
}
//进入表体
if(id==1){
//判断all的值 1进去,0弹出提示
if(all=0)
{
alert("请先保存表头");
return false;
}else (all=1)
{
if(document.getElementById("a").style.display=="block")
{
document.getElementById("a").style.display="none";
}
if(document.getElementById("a").style.display=="none")
{
document.getElementById("b").style.display="block";
}
}
}
}
我这个写的可是没效果啊~~~~~我是不是哪里写错了???
改成if(all == 0)