-1
我很努力地找到下面的解決方案。我有一個用戶可以輸入信息的HTML頁面。有8個變量需要輸入,一旦用戶點擊表單上的提交,我希望JQuery/JavaScript創建一個動態表條目,用所提供的信息填充頁面。JavaScript/jQuery從表單輸入數據動態構建HTML表格
我有表格片段我想我會用,但我不知道從哪裏開始與JS/JQ有這麼多的變量。在正確的方向任何指針將幫助
HMTL的表單數據:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Team Sheet</h1>
</div>
<div data-role="main" class="ui-content">
<a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all ui-icon-check ui-btn-icon-left">Show Popup Form</a>
<div data-role="popup" id="myPopup" class="ui-content" style="min-width:250px;">
<form method="post" action="/action_page_post.php">
<div>
<h3>Team Entry</h3>
<label for="usrnm" class="ui-hidden-accessible">Variable1:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable1">
<label for="usrnm" class="ui-hidden-accessible">Variable2:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable2">
<label for="usrnm" class="ui-hidden-accessible">Variable3:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable3">
<label for="usrnm" class="ui-hidden-accessible">Variable4:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable4">
<label for="usrnm" class="ui-hidden-accessible">Variable5:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable5">
<label for="usrnm" class="ui-hidden-accessible">Variable6:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable6">
<label for="usrnm" class="ui-hidden-accessible">Variable7:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable7">
<label for="usrnm" class="ui-hidden-accessible">Variable8:</label>
<input type="text" name="user" id="usrnm" placeholder="Variable8">
<input type="submit" data-inline="true" value="Submit">
</div>
</form>
</div>
</div>
<div data-role="footer">
<h1>Get Calling!</h1>
</div>
</div>
</body>
</html>
動態HTML表片斷
<tr>
<td>Variable1</td>
<td>Variable2</td>
<td>Variable3</td>
<td><a href="Variable4" target="_blank" target="_blank" class="external-link" rel="nofollow">Variable5</a></td>
<td><a href="mailto:Variable6" class="external-link" rel="nofollow">Variable6</a></td>
<td><a href="mailto:Variable7" class="external-link" rel="nofollow">Variable7</a></td>
<td>Variable8</td>
</tr>
ID必須是唯一的 – Andreas
什麼是'action_page_post.php'?你需要PHP在這裏扮演一個角色嗎? – trincot