0

Hi all i have a text box where i want to add total on sharepoint online from a calculated field. The problem here is after reaload the data in the textbox dissapiers. how do i keep the value after a reload.

   function success(sender, args) {
                //  alert('Added to chart!');
                // window.location.reload(true);
                location.reload();
                document.getElementById('Text1').value = "test";
                AddTotal();
            }

            function AddTotal()
            {
                alert("test 1");
                document.getElementById('Text1').value = "test";
            }
2
  • what is the purpose to reload a page in success callback? Commented Jan 8, 2018 at 6:25
  • i am moving list item from one list to another. once copied it reloads so that the users can see the details moved. oligopolies the code is too big to be posted here
    – Rinu
    Commented Jan 8, 2018 at 6:36

2 Answers 2

0

local storage or session storage or cookie, you could check the thread shared by PratyushB for the difference.

https://scotch.io/@PratyushB/local-storage-vs-session-storage-vs-cookie

3
  • can we work with session objects in sharepoint ?
    – Rinu
    Commented Jan 8, 2018 at 10:44
  • I had used session in SharePoint 2010, msdn.microsoft.com/en-us/library/… . While it's server side object so you need maintain the life-cycle.
    – Lee
    Commented Jan 9, 2018 at 1:39
  • I was able to get it done with _spBodyOnLoadFunctionNames.push("MyFunction"); function MyFunction() { alert("page load"); alert(sessionStorage.getItem(total)); document.getElementById('Text1').value = sessionStorage.getItem(total); Total(); document.getElementById('Text1').value = sessionStorage.getItem("lastname"); };
    – Rinu
    Commented Jan 9, 2018 at 5:20
0

I think you should post this question in javasript stackexchange as, from what I can see, it's not related to SharePoint.

Have a look at storing the value in the user session using a key which includes the related item ID. Update this value on every change and load this value on pageload. Have a look here: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.