table data is clear after submitting the form
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
I am working with javascript
when I submit the form I store the data in a table but the table data is also clear
index.html
<body>
<form id=’freg’>
<label>firstname</label>
<input type=’text’ id=’fname’>
<label>lastname</label>
<input type=’text’ id=’lname’>
<label>officelocation</label>
<input type=’text’ id=’location’>
<input id=’btn’ type=’submit’ value=’submit’ onclick=’onFormSubmit()’/>
</form>
<br/> <br/>
<table>
<thead>
<tr>
<th>firstname</th>
<th>lastname</th>
<th>location</th>
</tr>
</thead>
<tbody>
<td id=’ffname’></td>
<td id=’llname’></td>
<td id=’olocation’></td>
</tbody>
</table>
<script type=’text/javascript’ src=’index.js’></script>
index.js
function onFormSubmit() {
document.getElementById(‘fname’).value;
document.getElementById(‘lname’).value;
document.getElementById(‘location’).value;
readFormData();
}
function readFormData() {
var data = {};
data.fname = document.getElementById(‘fname’).value;
data.lname = document.getElementById(‘lname’).value;
data.location = document.getElementById(‘location’).value;
insertnewrecord(data);
}
function insertnewrecord(data) {
document.getElementById(‘ffname’).innerHTML = data.fname;
document.getElementById(‘llname’).innerHTML = data.lname;
document.getElementById(‘olocation’).innerHTML = data.location;
resetform();
}
function resetform() {
document.getElementById(‘fname’).value = “”;
document.getElementById(‘lname’).value = “”;
document.getElementById(‘location’).value = “”;
}
I am working with html with javascript
when I submit the form then not able to see the data in table I put debug and I can see the data is store in table but then tabale data is clear.
أضف إجابة