網站首頁 編程語言 正文
閱讀目錄
- 實現效果
- HTML
- php
實現效果
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<style>
#mform{ margin: 10px; }
#mtable{ border-collapse: collapse; }
#mtable thead th,#mtable thead td{ min-width: 120px; }
#mdiv{ display: none; }
</style>
姓名:<input type="text" name="name" value="">
學歷:<input type="text" name="education" value="">
年齡:<input type="text" name="age" value="">
<input id="add" type="button" value="添加"><br>
<form id="mform" action="" method="post">
<table id="mtable" border="1">
<thead>
<tr>
<th>姓名</th>
<th>學歷</th>
<th>年齡</th>
</tr>
</thead>
<tbody id="mtbody">
</tbody>
</table>
<div id="mdiv"></div>
<input id="sub" type="button" value="提交"><br>
</form>
<script>
$(function(){
//添加tr
$('#add').click(function(){
var name = $("input[name='name']").val();
var education = $("input[name='education']").val();
var age = $("input[name='age']").val();
var html = '';
html += '<tr>';
html += '<td class="name">'+name+'</td>';
html += '<td class="education">'+education+'</td>';
html += '<td class="age">'+age+'</td>';
html += '</tr>';
$('#mtbody').append(html);
});
//提交
$('#sub').click(function(){
$('#mdiv').html('');
$.each($('#mtbody tr'),function(k){
var name = $('.name', this).text();
var education = $('.education', this).text();
var age = $('.age', this).text();
var html = '';
html += '<input type="text" name="data[' + k + '][name]" value="' + name + '">';
html += '<input type="text" name="data[' + k + '][education]" value="' + education + '">';
html += '<input type="text" name="data[' + k + '][age]" value="' + age + '"><br>';
$('#mdiv').append(html);
});
var data = $("#mform").serialize();
$.ajax({
type: "POST",
data: data,
url: "http://example.com/api/excel_import_export",
dataType: 'json',
success: function (json) {}
});
});
});
</script>
</body>
</html>
php
<?php
echo '<pre>';
print_r($_POST);
/*
結果為:
array:2 [
"data" => array:2 [
0 => array:3 [
"name" => "wgchen"
"education" => "撒"
"age" => "都是"
]
1 => array:3 [
"name" => "wgchen阿薩德"
"education" => "撒阿薩德"
"age" => "都是阿薩德"
]
]
"s" => "/api/excel_import_export"
]
*/
原文鏈接:https://blog.csdn.net/weiguang102/article/details/125545552
相關推薦
- 2022-10-19 報錯No?module?named?numpy問題的解決辦法_python
- 2022-05-09 python?itertools包內置無限迭代器_python
- 2023-07-26 webpack原理之開發第一個loader
- 2022-10-03 Golang實現HTTP編程請求和響應_Golang
- 2023-01-07 利用Linux?Find命令快速查找文件方法_linux shell
- 2022-08-13 beginInvoke加回調函數lamad
- 2022-12-05 關于EF的Code?First的使用以及踩坑記錄_實用技巧
- 2022-04-18 啟動項目: getaddrinfo ENOTFOUND localhost
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支