如何自动将媒体添加到新行/列

时间:2017-02-04 12:51:09

标签: php html mysqli html-table

我正在使用PHP和MySQLi构建一个儿童网页游戏,我现在正在制作一个页面,其中的图片和音频在表格中排序,左侧显示图片,右侧显示音频: enter image description here

我想要做的是,我想添加一个按钮,用户可以选择其他图片和音频,选中后,它会自动将媒体添加到新行中,如下所示:enter image description here我找到了一个添加新行的方法,但是当我重新加载页面时它会消失。代码

<body>
	<button onclick="myFunction()">Add new row</button>

	<table border="1" align="center" id="table1">
		<tr>
			<td><img src="images/croc.png" width="200"></td>
			<td><audio controls src="music/crocodile.mp3"></audio>
		</tr>
		<tr>
			<td><img src="images/caution.png" width="200"></td>
			<td><audio controls src="music/crocodile.mp3"></audio>
		</tr>
	</table>
	<script>
	function myFunction() {
    var table = document.getElementById("table1");
    var row = table.insertRow(-1);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    cell1.innerHTML = "NEW CELL1";
    cell2.innerHTML = "NEW CELL2";
	}
</script>
</body>
</html>

我是否知道如何自动浏览文件,将用户选择的媒体永久添加到网页中新表格的行中?

0 个答案:

没有答案