-1
我想將創建的元素保存到數據庫。所以當我刷新頁面時,創建的元素仍然在頁面上。請幫助我,謝謝。如何使用javascript創建HTML元素並將其保存到數據庫MySql
document.getElementById("insert").onclick = function(){
if(document.getElementById('number').value !== ""){
\t var a = document.createElement('a'); \t \t \t
a.className = "button fit icon fa-warning";
\t a.href = "tel:" + document.getElementById('number').value; \t \t var c = document.getElementById('nama').value;
\t a.innerHTML = c;
\t \t \t \t \t \t
\t var container = document.getElementById('linkcontainer');
\t container.appendChild(a); \t \t \t
} \t \t \t
} \t \t \t
<input type="text" name="nama" id="nama" value="" placeholder="Input Name" required>
<input type="text" name="number" id="number" value="" placeholder="Input Number" required>
<button name="insert" id="insert" class="button">Add Number</button>
<div id="linkcontainer"></div>