inherit
216224
0
Aug 1, 2024 1:18:46 GMT -8
Quozzo
408
November 2014
quozzo
|
Post by Quozzo on Apr 12, 2016 11:28:43 GMT -8
Hi aRMY83I noticed you are struggling with if statements and were using jQuery incorrectly in the original post. I'm not sure what your JavaScript capabilities are but it would be best if you looked at some tutorials regarding variables, if statements, functions and the like before moving on to localStorage/cookies as they act differently than anything else.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Apr 12, 2016 13:52:27 GMT -8
Thanks for the advice Quozzo and as you know, so people are "book smart" and there's others like myself, that are "hands on" when learning things. I have and still do read about Javascript, CSS, HTML and the list goes on and find it hard to comprehend the amount of "how to do that" from all the reading I have done. I know it's never to old to learn, but getting up there in years with a few disabilities, I find myself asking for assistance on the "how to" do this or that and by no means do I abuse it. Once again, thanks for the advice and greatly appreciated.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Apr 12, 2016 14:36:10 GMT -8
aRMY83, Would you be willing to post your whole code? I might have spotted an error, but the code you had last posted didn't have your localStorage use in it.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Apr 12, 2016 14:41:29 GMT -8
Hello Lynx Thanks for the reply and here is the code: var armyHide = localStorage["hide"]; //default if doesn't exist
if(armyHide==undefined) armyHide = "hide" $(document).ready(function(){
//if set to hide, run your start function (which hides your div) if(armyHide=="hide") $('#start').click()
$('#stop').click(function(){
$('#mymarquee').hide();
$('#mdivx1').show(); //if click stop set div to show
localStorage["hide"] = "show" });
$('#start').click(function(){
$('#mymarquee').show();
$('#mdivx1').hide();
//if click start set div to hide again localStorage["hide"] = "hide"
});
});
|
|
inherit
216224
0
Aug 1, 2024 1:18:46 GMT -8
Quozzo
408
November 2014
quozzo
|
Post by Quozzo on Apr 12, 2016 15:22:06 GMT -8
aRMY83 , Your localStorage really isn't doing anything - it's missing a .setItem or .getItem. Your top line: var armyHide = localStorage("hide"); should be: var armyHide = localStorage.getItem("hide"); That's not true. it's working fine. It's treated like an object. Note the square brackets instead of curly braces as in your example.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Apr 12, 2016 15:24:12 GMT -8
Ignore my post above, aRMY83. I'll just keep my mouth shut and let the experienced coders help you. Edit: I just deleted my post above so it doesn't create confusion.
|
|
inherit
216224
0
Aug 1, 2024 1:18:46 GMT -8
Quozzo
408
November 2014
quozzo
|
Post by Quozzo on Apr 12, 2016 15:28:01 GMT -8
The problem lies with if statements and their placement. I don't want to spoonfeed though. This is basic stuff which is why it would be easier to read a tutorial. I'm also again't re-inventing the wheel and repeating what could easily be Googled.
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Apr 12, 2016 15:33:00 GMT -8
Hello Lynx Thanks for the reply and here is the code: var armyHide = localStorage["hide"]; //default if doesn't exist
if(armyHide==undefined) armyHide = "hide" $(document).ready(function(){
//if set to hide, run your start function (which hides your div) if(armyHide=="hide") $('#mdivx1').hide();
$('#stop').click(function(){
$('#mymarquee').hide();
$('#mdivx1').show(); //if click stop set div to show
localStorage["hide"] = "hide" });
$('#start').click(function(){
$('#mymarquee').show();
$('#mdivx1').hide();
//if click start set div to hide again localStorage["hide"] = "show"
});
}); You mean the reverse like that?
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Apr 14, 2016 13:28:31 GMT -8
This has been resolved and would like to take this opportunity to thank everyone who gave their advice/input and as always, greatly appreciated.
|
|