页面值与值的传递<js>

这两窗口之间存在着关系.父窗口Test1.html打开子窗口Test2.html
子窗口可以通过window.opener指向父窗口.这样可以访问父窗口的对象.
Test1.htm

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script>
        function set() {
            //由于是一个新的技术,你可以通过下面的代码检测你的浏览器是否支持
            if (window.localStorage) {
                //存储变量的值
                localStorage.name = document.all.username.value;
                location.href = 'Test2.html';//跳转的页面
            } else {
                alert("NOT SUPPORT");
            }
        }
    </script>
</head>
<body>
    <input type="text" name="username" />
    <input type="button" name="" value="post" onclick="set()"/>
</body>
</html>

 

Test2.html

<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script>
        var value = localStorage["name"];
        alert(value);
    </script>
</head>
<body>

</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,为了实现批量删除,我们需要将前端页面中的删除按钮改为复选框,并在表单中添加一个提交按钮。同时,我们还需要给每个复选框设置一个value属性,用于存储对应新闻的ID。修改后的代码如下: ```html <form action="batchDeleteNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"><br><br> <table border="1" width="70%" cellpadding="0" cellspacing="0"> <tr align="center"> <td>选择</td> <td>编号</td> <td>标题</td> <td>类型</td> <td>发布人</td> <td>发布日期</td> <td>状态</td> <td>是否头条</td> <td colspan="4">操作</td> </tr> <c:forEach items="${newsList}" var="news"> <tr align="center"> <td><input type="checkbox" name="newsIds" value="${news.nid}"></td> <td>${news.nid}</td> <td>${news.title}</td> <td>${news.type}</td> <td>${news.userName}</td> <td>${news.pubtime}</td> <td> <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> </td> <td> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> </td> <td>${news.top==0?"是":"否"}</td> <td> <a href="NewsDetail?nid=${news.nid}&op=show">查看</a> <a href="NewsDetail?nid=${news.nid}&op=update">修改</a> <c:if test="${user.rule==0}"> <a href="javascript:void(0);" onclick="deleteNews(${news.nid})">  删除</a> </c:if> <c:if test="${user.rule==0}">  审核</c:if> </td> </tr> </c:forEach> </table> <button type="submit">批量删除</button> </form> ``` 上面的代码中,我们给复选框设置了name属性为"newsIds",并将对应的新闻ID作为value传递到后端。在表格的最后,我们添加了一个提交按钮,用于提交批量删除的请求。同时,我们还将原来的删除按钮改为了一个超链接,点击时会执行一个JavaScript函数,用于删除单个新闻。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值