網(wǎng)站首頁 編程語言 正文
閱讀目錄
- 實現(xiàn)效果
- HTML
- php
實現(xiàn)效果
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="">
學(xué)歷:<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>學(xué)歷</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);
/*
結(jié)果為:
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
相關(guān)推薦
- 2022-10-03 Go?Excelize?API源碼閱讀Close及NewSheet方法示例解析_Golang
- 2022-07-18 Pod創(chuàng)建多個容器并訪問指定容器
- 2022-04-21 新一代Python包管理工具_(dá)python
- 2022-05-23 Jenkins實現(xiàn)集群化管理以及流水線項目配置_nginx
- 2022-10-01 如何在Python中對文件進(jìn)行操作_python
- 2022-09-04 mat矩陣和npy矩陣實現(xiàn)互相轉(zhuǎn)換(python和matlab)_python
- 2023-01-03 C++?Boost?MetaStateMachine定義狀態(tài)機超詳細(xì)講解_C 語言
- 2022-09-17 ComposeDesktop開發(fā)桌面端多功能APK工具_(dá)Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支