ajax初始化和select-option :change获取相应的值

本文介绍了一个包含多种网页元素的示例页面,通过使用HTML、CSS和JavaScript实现了页面布局和交互功能。其中包括按钮点击事件处理、AJAX数据请求及响应处理等。文章展示了如何通过CSS设置元素样式并实现特定布局效果。
<!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="jquery-3.0.0.min.js"></script>
</head>
<style>
  .container {
            width: 800px;
            height: 600px;
            border: 2px solid #000;
        }
.grade-list {
            height: 40px;
            border-bottom: 1px solid #999;
            margin-bottom: 20px;
            margin-top: 20px;
        }
.grade-list  span{
display:block;
width:20px;
height:20px;
border: 1px solid #000;
/*浮动一次*/
float: left;
}
.label_btn {
/*浮动2次*/
            float: left;
            margin-right: 10px;
        }
.butActive {
            background: violet;
        }
          .second_box {
            position: relative;
        }




</style>


<body>
  <!-- 叶子类目展示内容-->
   <div class="container">
    <!-- 叶子类目展示内容-->
        <div class="grade-list clearfix" id="tel">
        <div class="label_btn clearfix"><span id="50023643" class="cc"></span><label>棒球鞋</label></div>
        <div class="label_btn clearfix"><span id="50005900" class="cc"></span><label>足球鞋</label></div>
        <div class="label_btn clearfix"><span id="50023643" class="cc"></span><label>球鞋</label></div>
        <div class="label_btn clearfix"><span id="50005900" class="cc"></span><label>女生上衣</label></div>
        <div class="label_btn clearfix"><span id="125612007" class="cc"></span><label>男生上衣</label></div>
        <div class="label_btn clearfix"><span id="125612008" class="cc"></span><label>毛巾</label></div>
        <div class="label_btn clearfix"><span id="125612009" class="cc"></span><label>鸭翅</label></div>
         <button class="indexBtn" id="loadBtn">加载</button>
        </div>
        <!-- 开始时间和结束时间 -->
        <div class="second_box">
          <label>开始时间:</label> <input type="text" id="begin" placeholder="开始时间" value=""> --
            <label>结束时间:</label> <input type="text" id="end" placeholder="结束时间" value="">
          <!-- 类型下拉框 -->
            <select id="selectOption">
<option>类目属性</option>
<option>活跃店铺</option>
<option>宝贝</option>
</select>
        
        </div>
        
        
        
        
        
        
        
        
        
   </div>








<script>
//切换选项卡
$(".label_btn>span").click(function(){
$(this).toggleClass("butActive");
});

function index(param)
{
$.ajax({
url:"http://211.95.60.40:16868/yanshudemo/shop",
type:'POST',
data:{
type: param
},
dataType:"json",
success:function(data){
console.log(data.columns.length);
},error:function(){
  alert("数据开小差了");
}

})
}


//初始化选中项
        var selectop = $("#selectOption option:selected").val();
        index(selectop);

////下拉框改变事件
$("#selectOption").change(function(){
var selectop=$("#selectOption").val();
index(selectop);
})





</script>














</body>
</html>
那如何將<!-- 数据表格区域,带滚动与分页 --> <div style="width: 95%;margin-left: 28px;margin-top: 25px;"> <!-- 表格标题,动态显示当前周/月 --> <caption style="margin-top: 10px;color: blue;">{{weeks}}:</caption> <!-- 使用 Bootstrap 样式的表格 --> <table class="table table-condensed table-hover table-striped table-bordered table-advanced tablesorter" cellspacing="0" cellpadding="4" id="Body_Gd" style="border-collapse:collapse;"> <!-- 表头 --> <thead> <tr class="btn-primary"> <!-- 使用 btn-primary 类给表头着色 --> <th scope="col" style="white-space:nowrap;">序號</th> <th scope="col" style="white-space:nowrap;">日期</th> <th scope="col" style="white-space:nowrap;">送修單位</th> <th scope="col" style="white-space:nowrap;">品名</th> <th scope="col" style="white-space:nowrap;">型號</th> <th scope="col" style="white-space:nowrap;">ISN</th> <th scope="col" style="white-space:nowrap;">單價</th> <th scope="col" style="white-space:nowrap;">報修人員</th> <th scope="col" style="white-space:nowrap;">不良現象</th> <th scope="col" style="white-space:nowrap;">狀態</th> <th scope="col" style="white-space:nowrap;">出庫日期</th> <th scope="col" style="white-space:nowrap;">維修人員</th> <th scope="col" style="white-space:nowrap;">不良原因</th> <th scope="col" style="white-space:nowrap;">更換脚位</th> <th scope="col" style="white-space:nowrap;">信號</th> <th scope="col" style="white-space:nowrap;">是否命中</th> </tr> </thead> <!-- 表体:使用 Django 模板语言循环渲染数据 --> <tbody id="scrollBody1"> {% if queryset %} {% for item in queryset %} <tr> <td style="white-space:nowrap;">{{item.0}}</td> <!-- 序号 --> <td style="white-space:nowrap;">{{item.1}}</td> <!-- 日期 --> <td style="white-space:nowrap;">{{item.2}}</td> <!-- 送修单位 --> <td style="white-space:nowrap;">{{item.3}}</td> <!-- 品名 --> <td style="white-space:nowrap;">{{item.4}}</td> <!-- 型号 --> <td style="white-space:nowrap;">{{item.5}}</td> <!-- ISN --> <td style="white-space:nowrap;">{{item.6}}</td> <!-- 单价 --> <td style="white-space:nowrap;">{{item.7}}</td> <!-- 报修人员 --> <td style="white-space:nowrap;">{{item.8}}</td> <!-- 不良现象 --> <td style="white-space:nowrap;">{{item.11}}</td> <!-- 状态 --> <td style="white-space:nowrap;">{{item.10}}</td> <!-- 出库日期 --> <td style="white-space:nowrap;">{{item.12}}</td> <!-- 维修人员 --> <td style="white-space:nowrap;">{{item.13}}</td> <!-- 不良原因 --> <td style="white-space:nowrap;">{{item.14}}</td> <!-- 更换脚位 --> <td style="white-space:nowrap;">{{item.15}}</td> <!-- 信号 --> <td style="white-space:nowrap;">{{item.16}}</td> <!-- 是否命中 --> </tr> {% endfor %} {% else %} <!-- 如果没有数据,则显示提示信息 --> <tr> <td colspan="16" style="color: red;">無維修OK設備記錄</td> </tr> {% endif %} </tbody> </table> <!-- 分页组件 --> <div class="page clearfix"> <div class="pull-right"> <!-- 右对齐 --> <ul class="pagination"> <!-- 显示总条数当前页码 --> <div class="pull-left"> <span class="btn btn-primary" style="width: 100px;font-size:14PX;">共{{total_count}}条數據</span> <span class="btn btn-primary" style="width: 100px;font-size:14PX;">第{{page}}/{{total_page_count}}頁</span> </div> <!-- 动态生成的分页链接(由后端传入 page_string 渲染) --> {{page_string}} </ul> </div> </div> </div> 放入到{% load static %} <!-- 加载 Django 的 static 模板标签,用于引用静态文件(CSS/JS/图片等) --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- 声明文档字符编码为 UTF-8,支持中文 --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- 响应式视口设置 --> <title>設備修復率</title> <!-- 页面标题 --> <!-- 引入 Bootstrap CSS 样式文件,用于基础样式表格美化 --> <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.css' %}"> <style> /* 响应式容器:包裹图表控件的主要区域 */ .chart-container { position: relative; /* 相对定位,作为内部绝对定位元素的参考 */ width: 99vw; /* 宽度占视窗宽度的99%,接近全屏 */ height: 95vh; /* 高度占视窗高度的95% */ min-width: 600px; /* 最小宽度限制,防止在小屏幕上过窄 */ min-height: 400px; /* 最小高度限制 */ margin: 20px auto; /* 上下外边距20px,左右自动居中 */ } /* 时间周期选择下拉框样式 */ #timePeriod { position: absolute; /* 绝对定位,脱离文档流 */ left: 10%; /* 距离左侧10% */ top: 20px; /* 距离顶部20px */ z-index: 999; /* 层级最高,确保显示在其他内容之上 */ width: 100px; height: 30px; font-size: 14px; } /* “顯示週期”标签样式 */ label { position: absolute; left: 5%; /* 稍微靠左于下拉框,形成对齐 */ top: 25px; font-weight: bold; color: #666; /* 灰色字体 */ } /* 图表下方说明文字样式 */ .explanation { position: absolute; bottom: 10px; /* 固定在容器底部上方10px */ left: 5%; color: #2196F3; /* 蓝色文字(类似 Material Blue) */ font-size: 14px; } /* 主要图表区域的高度控制 */ .chart-main { height: 85vh; /* 占据大部分视窗高度 */ } </style> </head> <body> <!-- 主容器:包含图表、筛选器、表格与分页 --> <div class="chart-container"> <!-- 下拉框标签 --> <label for="timePeriod">顯示週期:</label> <!-- 时间周期选择器 --> <select id="timePeriod" class="form-control"> <option value="month">月報表</option> <option value="week">週報表</option> </select> <!-- ECharts 图表渲染区域(目前只显示周报图表) --> <div id="xiufulv_week" class="chart-main"></div> <!-- 计算公式说明 --> <div class="explanation"> <div>計算公式:</div> <div> 修復率 = (出庫修復數 / 出庫數) * 100%</div> </div> </div> <!-- 引入必要的 JS 文件 --> <script src="{% static 'js/jquery.js' %}"></script> <!-- jQuery 库 --> <script src="{% static 'js/echarts5.4.js' %}"></script> <!-- Apache ECharts 5.4 图表库 --> <script src="{% static 'js/wanxiulv_week.js' %}"></script> <!-- 自定义脚本:初始化图表并处理交互逻辑 --> <!-- 注意:当前只加载了 week 图表脚本,缺少 month 切换逻辑 --> </body> </html>
最新发布
12-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值