-1

i have a dynamic add a href, on page refresh all the a href's added disappear. Is this normal or can i store it, to ensure the links added do not disappear.

      $(document).on('click', 'li#order', function(){
                 
                    $(this).before('<li><a href="Franchise-Rest-Details.php">HO</a></li>');
                        
                    // add to localsorage? 
                    window.onload = function(){
                    } 
                    var order_open = $('div#Rest').html();
                    localStorage.setItem('div#Rest', order_open);
                });
               
               
            <!--Restaurant toggle -->
            <a id="restt" class ="header"href="#" onclick="toggleVisibility('Rest');"><h3>Your Restaurants</h3></a>
            <div id="Rest" style="display: none;"><div>

                    <ul class="tabs">
                        <li id="order" class="rred"><a class="sb" href="Franchise-account-orders.php">restaurant</a></li>
                        <li id="order" class="rgreen"><link class="sb">New restaurant</a></li>

                    </ul>

                </div>
            </div>

what is the best way to achieve this.

The a refs are successfully added but just do not stay when refreshed.

jerneva
  • 473
  • 1
  • 8
  • 25

1 Answers1

0

You can use some flag to save tags info in backend or in front end can use cookie to determine that after ahref tag code execution, Page has been refreshed so ahref tag will not disappear.

Hope this helps, Otherwise I will add code here.

AbhiNickz
  • 1,035
  • 2
  • 14
  • 32
  • sorry i am new to this, i know how cookies work but would have know idea how to save information into them. The information would have to stay permanently so are visible every time someone signs into their admin account. so would it be better to use sessions instead? – jerneva Apr 02 '16 at 13:31
  • Session variable can be set using server side, Otherwise you have to use javascript to create cookies achieve this. [This seems like would solve your problem.](http://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript), What backend language and framework you are using for this? I have done this using Perl and Template toolkit on Catalyst Framework. – AbhiNickz Apr 03 '16 at 21:38