如何通过请求从另一个HTML页面将数据添加到行中来向一个HTML页面中的表添加行(可能使用"prompt&qu
How to add rows to table in one HTML page by asking for data to be added into rows from another HTML page (may be using "prompt" & javascripts)?
我使用了以下代码:
Form1.html
<html>
<head>
<title>Table of Data</title>
</head>
<body>
<form method="POST">
<table border="1" id="tblQuery">
<tr>
<th>Query</th>
<th>Answer</th>
<th>Data Type</th>
<th>Screen No.</th>
</tr>
<tr>
<td>Name</td>
<td><input type="text"/></td>
<td>Textbox</td>
<td>1</td>
<td><input type="button" value="Edit" /><input type="button" value="Delete" /></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="gender" value="male" />Male<br><input type="radio" name="gender" value="female" />Female</td>
<td>Radio Buttons</td>
<td>2</td>
<td><input type="button" value="Edit" /><input type="button" value="Delete" /></td>
</tr>
<tr>
<td>Qualification</td>
<td><input type="checkbox" name="qualification" value="graduate" />Graduate<br><input type="checkbox" name="qualification" value="post graduate" />Post Graduate</td>
<td>Checkbox</td>
<td>1</td>
<td><input type="button" value="Edit" /><input type="button" value="Delete" /></td>
</tr>
<tr>
<td>City</td>
<td><select>
<option value="new_delhi">New Delhi</option>
<option value="mumbai">Mumbai</option>
<option value="kolkata">Kolkata</option>
<option value="chennai">Chennai</option>
</select></td>
<td>Select List</td>
<td>4</td>
<td><input type="button" value="Edit" /><input type="button" value="Delete" /></td>
</tr>
<tr>
<td>Academic Record</td>
<td><input type="button" value="Add Table" onclick="addTable.html" /></td>
<td>Table</td>
<td>3</td>
<td><input type="button" value="Edit" /><input type="button" value="Delete" /></td>
</tr>
</table>
<br>
</form>
</body>
</html>
Form2.html
<html>
<head>
<title>Action</title>
<script src="scripts/newQuery.js"></script>
</head>
<body>
<input type="button" value="Add Query" onclick="openPage()" />
<input type="button" value="Create Metafile" />
</body>
</html>
之后,我使用"frameset"
元素将这两个页面添加到"index.html"
文件中,如下所示:
index . html
<html>
<head>
<title>Main Application case Study</title>
</head>
<frameset rows="75%, *">
<frame src="Form.html" />
<frame src="Form2.html" />
</frameset>
</html>
现在如果我打开"index.html"
页面&点击"Add Query"
按钮,我会收到一条"prompt"
消息,要求我添加查询&我将把它添加到"Form1.html"
页。
我在这里面临的问题是,当我提交要添加到表中的查询时,该查询实际上提交给"Form2.html"
页,因为"prompt"
在该页编码。但是我需要添加一行到"Form1.html"
。
我怎样才能实现它?
你把你的生活弄得太艰难了。
您想要打开一个页面,该页面打开的页面会做类似
的事情http://www.dzone.com/snippets/add-rows-html-tablefunction addRow(table,content,morecontent,evenmorecontent) {
var tabBody=table.getElementsByTagName("TBODY")[0];
var row=document.createElement("TR");
var cell1 = document.createElement("TD");
var cell2 = document.createElement("TD");
var cell3 = document.createElement("TD");
var textnode1=document.createTextNode(content);
var textnode2=document.createTextNode(morecontent);
var textnode3=document.createTextNode(evenmorecontent);
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
cell3.appendChild(textnode3);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
tabBody.appendChild(row);
}
var table = opener.opener.document.getElementById("tblQuery");
addRow(table,"cell1 content","cell2 content","cell3 content");
相关文章:
- 基于用户垂直滚动向HTML表添加行
- 提交表单时如何在 HTML 表格中添加行
- 使用JS向html表添加行
- 有没有一种方法可以用javascript将原始html添加为新的表行
- 向表中添加行的 Html
- 使用量角器在 HTML 表格中添加行计数 - 非角度
- 在HTML表中显示JSON,并添加行
- CakePHP 2.0添加html表行
- 使用JavaScript在HTML表中动态添加行,并通过提交按钮获得每个文本框的文本框值
- 将css添加到html中表的动态添加行中
- 如何使用JS、HTML添加换行符和函数
- 将HTML输入文件中的文件添加到各个HTML表行中
- 如何避免第一行被删除,同时使用DOM添加和删除html表行
- 用jquery添加html表行不能设置为标记
- 为什么我不能动态地向HTML表中添加行?
- 如何使用JS或angular JS在html中添加行后本地存储表
- 当数据来自 HTML 元素时,如何使用 jQuery 向表中添加行
- 不能通过Javascript更改表的内部HTML来添加行
- Javascript添加行到HTML表与文本和onClick
- 如何通过请求从另一个HTML页面将数据添加到行中来向一个HTML页面中的表添加行(可能使用"prompt&qu