addykha
addykha

Reputation: 61

Can i permanently change the value and the label of a html button?

I'm making a simple personal management system that keeps track of what you did yesterday based on the activities(buttons) you clicked. The activities(buttons) should be editable, which i can do easily using jquery, but i want it to be permanently changed even if i reload the page.

<div id='action-container'>
<div class='actions'>
<button id='action1' class="action" data-value="Wash Dishes">Wash Dishes</button>
<button>Edit Button 1</button></div>
</div>

if there is a way, how should i do it?

Upvotes: 4

Views: 681

Answers (2)

T.J. Crowder
T.J. Crowder

Reputation: 1075009

You can use cookies (for small bits of information), or (on modern browsers) local storage, both of which store the state client-side (in the browser).

For centralized storage, you'll need either to store it on your own server or integrate with something like Google Apps, which has a rich API and feature set, or DropBox, or any of several others.

Upvotes: 1

Adil
Adil

Reputation: 148150

If you want to save the state on server then you can save the state in hidden field which is server accessible and access that field on postback and save the state where you want. If you want to save state on client you can use client storage

In html

<input type="hidden" runat="server" id="hdnstate" />

In javascript

document.getElementById('<%= hdnstate.ClientId %>').value = "stateinfo";

In Code behind

string strState = hdnstate.Value;

Upvotes: 1

Related Questions