开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1669|回复: 23
收起左侧

[Web源码] 【前端】学生就业登记表案例

[复制链接]
结帖率:0% (0/1)
发表于 2023-12-11 15:07:22 | 显示全部楼层 |阅读模式   新疆维吾尔自治区伊犁哈萨克自治州
分享源码
界面截图: -
是否带模块: -
备注说明: -
页面刷新数据不会丢失:  使用了本地存储代码。
ez9hf-95b18.gif
2023-12-11_150050.png

评分

参与人数 1好评 +1 精币 +3 收起 理由
空竹 + 1 + 3 开源精神必须支持~

查看全部评分


结帖率:84% (32/38)

签到天数: 9 天

发表于 2024-1-12 22:57:57 | 显示全部楼层   湖北省荆州市
感谢分享,很给力!~
回复 支持 反对

使用道具 举报

签到天数: 10 天

发表于 2023-12-18 18:29:40 | 显示全部楼层   四川省绵阳市
感谢分享,很给力!~
回复 支持 反对

使用道具 举报

签到天数: 11 天

发表于 2023-12-17 19:25:03 | 显示全部楼层   江苏省连云港市
谢谢分享
回复 支持 反对

使用道具 举报

签到天数: 8 天

发表于 2023-12-14 14:11:05 | 显示全部楼层   江苏省连云港市
感谢分享,很给力!~
回复 支持 反对

使用道具 举报

签到天数: 30 天

发表于 2023-12-12 23:13:49 | 显示全部楼层   广东省揭阳市
新技能已get√
回复 支持 反对

使用道具 举报

签到天数: 9 天

发表于 2023-12-12 17:57:51 | 显示全部楼层   河南省开封市
开源精神必须支持~
回复 支持 反对

使用道具 举报

结帖率:68% (41/60)
发表于 2023-12-12 17:52:10 | 显示全部楼层   山东省滨州市
支持开源~!感谢分享
回复 支持 反对

使用道具 举报

结帖率:70% (7/10)

签到天数: 30 天

发表于 2023-12-12 15:02:19 | 显示全部楼层   河南省焦作市
支持开源~!感谢分享
回复 支持 反对

使用道具 举报

结帖率:0% (0/1)
 楼主| 发表于 2023-12-12 11:36:37 | 显示全部楼层   新疆维吾尔自治区伊犁哈萨克自治州
[JavaScript] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生就业登记表</title>
    <style>
        body {
            background-color: #fff;
        }

        .wrapper {
            width: 700px;
            height: 400px;
            margin: 100px auto;
        }

        .inner {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 40px;
        }

        .p-1 {
            width: 50px;
            border-radius: 2px;
        }

        .info {
            display: flex;
            justify-content: space-around;
            margin-top: 10px;
            width: 100%;
            height: 40px;
        }

        .btn {
            width: 50px;
            height: 25px;
            border: none;
            color: #fff;
            cursor: pointer;
            background-color: #143875;
            border-radius: 2px;
        }

        select {
            border-radius: 2px;
        }

        .statistics {
            position: relative;
            display: flex;
            align-items: center;
            width: 100%;
            height: 40px;
            background-color: #F2F2F2;
        }

        .num {
            font-weight: bold;
            color: fuchsia;
        }

        .statistics_wrap {
            position: absolute;
            right: 10px;
            letter-spacing: 2px;
            font-size: 14px;
        }

        .list_wrap {
            width: 100%;
            margin-top: 10px;
            border-collapse: collapse;
        }

        .list_wrap tr {
            height: 40px;
            background-color: #F2F2F2;
        }

        .list_wrap th {
            border-collapse: collapse;
        }

        .t_tbody tr {
            font-size: 14px;
            text-align: center;
        }

        .t_tbody td {
            border-collapse: collapse;
        }

        .t_tbody a {
            background-color: crimson;
            display: block;
            border: none;
            border-radius: 2px;
            text-decoration: none;
            color: #fff;
        }
    </style>
</head>
<body>
<div class="wrapper">
    <div class="inner">
        <h3 class="title">学生就业登记表</h3>
    </div>
    <form class="info" autocapitalize="off">
        <label>姓名:<input type="text" class="p-1" name="uname"></label>
        <label>年龄:<input type="number" class="p-1" name="age"></label>
        <label>薪资:<input type="number" class="p-1" name="salary"></label>
        <label>
            性别:
            <select name="gender">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
        </label>
        <label>
            就业城市:
            <select name="city">
                <option value="乌鲁木齐">乌鲁木齐</option>
                <option value="吐鲁番">吐鲁番</option>
                <option value="塔城">塔城</option>
                <option value="伊犁">伊犁</option>
            </select>
        </label>
        <button class="btn">添加</button>
    </form>
    <div class="statistics">
        <div class="statistics_wrap">共有数据<span class="num">0</span>条</div>
    </div>

    <table class="list_wrap">
        <thead class="list">
        <tr>
            <th>ID</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>薪资</th>
            <th>就业城市</th>
            <th>录入时间</th>
            <th>操作</th>
        </tr>
        </thead>

        <tbody class="t_tbody">
        
        </tbody>
    </table>
</div>

<script>
    const intDate = [{
        stuId: 1,
        uname: '法外狂徒张三',
        age: 20,
        gender: '男',
        salary: '9.9',
        city: '各地',
        time: '2023/12/11 13:18:00'
    }]
    // 原数组对象以字符串的方式保存到本地存储

    //TODO:
    // 注意事项:第一次启动之后注释下面一行代码。
    // 注释方法:在代码最前端写//符号
    // 例子:               //localStorage.setItem('data', JSON.stringify(intDate))
    localStorage.setItem('data', JSON.stringify(intDate))

    // 以转换对象的方式读取原字符串数据
    const arr = JSON.parse(localStorage.getItem('data')) || []
    console.log(arr)
    const t_tbody = document.querySelector('.t_tbody')
    const num = document.querySelector('.statistics_wrap .num')
    const info = document.querySelector('.info')
    const p_1 = document.querySelectorAll('.info .p-1')
    const uname = document.querySelector('[name=uname]')
    const age = document.querySelector('[name=age]')
    const salary = document.querySelector('[name=salary]')
    const gender = document.querySelector('[name=gender]')
    const city = document.querySelector('[name=city]')

    function render() {
        const trArr = arr.map(function (ele, index) {
            return `
            <tr>
            <td>${ele.stuId}</td>
            <td>${ele.uname}</td>
            <td>${ele.age}岁</td>
            <td>${ele.gender}</td>
            <td>${ele.salary}元</td>
            <td>${ele.city}</td>
            <td>${ele.time}</td>
            <td>
                <a href="javascript:" data-id="${index}">删除</a>
            </td>
        </tr>
            `
        })

        t_tbody.innerHTML = trArr.join('')
        num.innerHTML = arr.length
    }

    render()

    info.addEventListener('submit', function (e) {
        e.preventDefault()

        for (let i = 0; i < p_1.length; i++) {
            if (!p_1.value) {
                return alert('用户输入不能为空!')
            }
        }

        arr.push({
            stuId: arr.length ? arr[arr.length - 1].stuId + 1 : 1,
            uname: uname.value,
            age: age.value,
            gender: gender.value,
            salary: salary.value,
            city: city.value,
            time: new Date().toLocaleString()
        })
        render()
        this.reset()
        localStorage.setItem('data', JSON.stringify(arr))
    })

    t_tbody.addEventListener('click', function (e) {
        if (e.target.tagName === 'A') {

            if (confirm('您确定要删除本条数据吗?')) {
                arr.splice(e.target.dataset.id, 1)
                render()
                localStorage.setItem('data', JSON.stringify(arr))
            }

        }
    })
</script>
</body>
</html>
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表