Remember choice from this link

  • jokerper
  • Novice
  • Novice
  • User avatar
  • Posts: 22

Post 3+ Months Ago

Hi

I need some help with this:

<li><a href="javascript:;" onclick="toggle123('vagtplan')" id="vagtplanlink">VIS VAGTPLAN</a></li>

Now I won to have have cookie set and remember the choice so it will be toggle correct on next visit.

Code: [ Select ]
    <script language="javascript">

    function toggle123(x)
    {
var ele = document.getElementById(x);
var text = document.getElementById(x + "link");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "VIS " + x;
}
else {
ele.style.display = "block";
text.innerHTML = "SKJUL " + x;
}
}

</script>
  1.     <script language="javascript">
  2.     function toggle123(x)
  3.     {
  4. var ele = document.getElementById(x);
  5. var text = document.getElementById(x + "link");
  6. if(ele.style.display == "block") {
  7. ele.style.display = "none";
  8. text.innerHTML = "VIS " + x;
  9. }
  10. else {
  11. ele.style.display = "block";
  12. text.innerHTML = "SKJUL " + x;
  13. }
  14. }
  15. </script>


something like

setcookie('block', $choice, time());

and then

document.getElementById(cookie['block'])

set the element block:none


Hope someone can help with this?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Have you tried setting a cookie in there or do you want someone to do that for you?

W3 Schools: JavaScript Cookies

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 93 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.