javascript - How to remove appended string from Cookie -


i have strings appended cookie , when user clicks button need string clicked removed cookie. strings within cookie exist need remain there.

the functions called through other api calls.

<html> <head>     <script type="text/javascript">         window.onload = function(){             document.getelementbyid('connstrings').innerhtml = "initialstring";             getprovidersfordisplay();         }             function savestringsstate(stringsfromevent)         {                 var stringconns = stringsfromevent.getconns;                 var div = document.getelementbyid('stringsconnected');                 div.innerhtml = div.innerhtml + " " + stringconns;                  cookies.set('connstrings', div.innerhtml);           }          function removestringpassed(removedstring)         {             var removedconnection = eventobj.provider;             var div = document.getelementbyid('stringsconnected');              div.innerhtml = div.innerhtml - removedstring;         }          function getprovidersfordisplay() {                 if((cookies.get('connstrings') != null)) {                     document.getelementbyid('stringsconnected').innerhtml = (cookies.get('connstrings'));                 } }     </script>    </head> <body>     <div id="strings">     <p>your strings are: <span id="stringsconnected"></span></p>     </div> </body> </html> 

the removestringspassed removes string passed lshows initial string nan not number , i'm doing minus. not being removed cookie actual strings set end being in same state.

can please me this? remove removedstring passed in current strings , cookie?

the cookie using here:https://github.com/js-cookie/js-cookie

thanks

edit:

i've added split string innerhtml seems have done it, setting cookie. replaces comma :/

edit: within removestringpassed i've used :

div.innerhtml = div.innerhtml.split(removedstring); div.innerhtml = div.innerhtml.join(""); cookies.set('provider', div.innerhtml); 

but replaces string commas, how can stop this?

i used in end , worked fine:

edit:

i've added split string innerhtml seems have done it, setting cookie. replaces comma :/

edit: within removestringpassed i've used :

div.innerhtml = div.innerhtml.split(removedstring); div.innerhtml = div.innerhtml.join(""); cookies.set('provider', div.innerhtml); 

but replaces string commas, how can stop this?

div.innerhtml = div.innerhtml.split(removedstring).join(""); 

Comments