Reputation: 185
i'm html newbie here so please be lenient with ur answer.
i want to permanently save changes made when i key in different value into the textbox for this html file. for now, everytime i refresh the browser, the data get back to the original value. haha, how do i change it so that the value that i entered will be saved instead, even after i close the tab and reopen it. thanks.
<table>
<tr>
<td>Current Limit</td>
<td> <div id="newlimit" >100</div> </td>
</tr>
<tr>
<td>Set New Limit</td>
<td><input type="number" id="updatelimit"></td>
</tr>
<tr>
<td><button onclick="fupdatelimit()">Save</button><td>
</tr>
<tr>
<td>Limit shown in RM</td>
</tr>
</table>
for javascipt,
function fupdatelimit() {
var y = document.getElementById("updatelimit").value;
newlimit.innerHTML= y;
}
thanks for ur help. :D
Upvotes: 2
Views: 10013
Reputation: 1942
EDIT after additional questions
think of it this way. Whenever you open any page on the web, some server sends an html file to your browser to be rendered. HTML itself it just a collection of markup (the table, buttons, textboxes) , everything else (images, content of textboxes etc.) is being loaded from the server (the same guy sending you the html file) , be it database, collection of static images or anything else.
you can certainly store your data in the text file, but it needs to be served from somewhere, most commonly all data pertinent to your website is to be stored in your server (database, images, text files). However the most common approach is to store data in the database. Why not just store in the text file? There are many reasons, but simply speaking same reason why you put your eggs in the egg packet and don't just put it on the floor.
if you want to learn server side scripting and databases, I'd suggest to pick up any for your taste. Most beginners start with PHP(Server side scripting) and MySQL(database), which is arguably the easiest and fastest solution to start with due to large number of tutorials for beginners.
Upvotes: 4
Reputation: 148
You need a database for that. Using PHP and MySQL you can do this easily. Enjoy your new adventure.
Upvotes: 0
Reputation: 23
You will need a server side language to save the update. Javascript is client side and runs on the browser only. The changes made with javascript will execute in the browser only, not in the server. When you reload, the server sends back the original file.
Upvotes: 0