Getting multiple if statements










0















I'm making an interactive series for my school project. We have some voice overs on the video's. So we have male and female voices. So I made a page with a button where they can choose between a male (man) and female(vrouw). the first if statement works like a charm. ( choosing between a male and female voice) after this, the user can choose between 2 choices in the video. But "choiceaman" doesn't work at all. Anyone an idea how I can make it work better. (FYI I'm not a coder usually so this is all new for me)



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man")
$("#pilotman").show();
$("#pilotvrouw").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#keuzemanvrouw").hide();


else if ($.cookie('keuzemanvrouw') == "vrouw")
$("#pilotvrouw").show();
$("#pilotman").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#keuzemanvrouw").hide();

else if ($.cookie('choice1') == "choiceaman")
$("#choiceaman").show();
$("#choicebman").hide();
$("#pilotman").hide();


else if ($.cookie('choice1') == "choiceavrouw")
$("#choiceavrouw").show();
$("#choicebvrouw").hide();
$("#pilotvrouw").hide();



else if ($.cookie('choice1') == "choiceman")
$("#choicebman").show();
$("#choiceaman").hide();
$("#pilotman").hide();




else
$("#pilotvrouw").hide();
$("#pilotman").hide();
$("#choiceavrouw").hide();
$("#choiceaman").hide();
$("#choicebvrouw").hide();
$("#choicebman").hide();

);









share|improve this question
























  • @PaulCrovella this is the script running on the page

    – Tim Roering
    Nov 13 '18 at 10:26











  • @TimRoering and it has nothing to do with PHP :)

    – Fyntasia
    Nov 13 '18 at 10:26











  • After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

    – yasoh
    Nov 13 '18 at 10:26











  • thats jquerry, right?:o

    – Leo Tahk
    Nov 13 '18 at 10:27











  • Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

    – Alive to Die
    Nov 13 '18 at 10:31















0















I'm making an interactive series for my school project. We have some voice overs on the video's. So we have male and female voices. So I made a page with a button where they can choose between a male (man) and female(vrouw). the first if statement works like a charm. ( choosing between a male and female voice) after this, the user can choose between 2 choices in the video. But "choiceaman" doesn't work at all. Anyone an idea how I can make it work better. (FYI I'm not a coder usually so this is all new for me)



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man")
$("#pilotman").show();
$("#pilotvrouw").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#keuzemanvrouw").hide();


else if ($.cookie('keuzemanvrouw') == "vrouw")
$("#pilotvrouw").show();
$("#pilotman").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#keuzemanvrouw").hide();

else if ($.cookie('choice1') == "choiceaman")
$("#choiceaman").show();
$("#choicebman").hide();
$("#pilotman").hide();


else if ($.cookie('choice1') == "choiceavrouw")
$("#choiceavrouw").show();
$("#choicebvrouw").hide();
$("#pilotvrouw").hide();



else if ($.cookie('choice1') == "choiceman")
$("#choicebman").show();
$("#choiceaman").hide();
$("#pilotman").hide();




else
$("#pilotvrouw").hide();
$("#pilotman").hide();
$("#choiceavrouw").hide();
$("#choiceaman").hide();
$("#choicebvrouw").hide();
$("#choicebman").hide();

);









share|improve this question
























  • @PaulCrovella this is the script running on the page

    – Tim Roering
    Nov 13 '18 at 10:26











  • @TimRoering and it has nothing to do with PHP :)

    – Fyntasia
    Nov 13 '18 at 10:26











  • After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

    – yasoh
    Nov 13 '18 at 10:26











  • thats jquerry, right?:o

    – Leo Tahk
    Nov 13 '18 at 10:27











  • Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

    – Alive to Die
    Nov 13 '18 at 10:31













0












0








0








I'm making an interactive series for my school project. We have some voice overs on the video's. So we have male and female voices. So I made a page with a button where they can choose between a male (man) and female(vrouw). the first if statement works like a charm. ( choosing between a male and female voice) after this, the user can choose between 2 choices in the video. But "choiceaman" doesn't work at all. Anyone an idea how I can make it work better. (FYI I'm not a coder usually so this is all new for me)



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man")
$("#pilotman").show();
$("#pilotvrouw").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#keuzemanvrouw").hide();


else if ($.cookie('keuzemanvrouw') == "vrouw")
$("#pilotvrouw").show();
$("#pilotman").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#keuzemanvrouw").hide();

else if ($.cookie('choice1') == "choiceaman")
$("#choiceaman").show();
$("#choicebman").hide();
$("#pilotman").hide();


else if ($.cookie('choice1') == "choiceavrouw")
$("#choiceavrouw").show();
$("#choicebvrouw").hide();
$("#pilotvrouw").hide();



else if ($.cookie('choice1') == "choiceman")
$("#choicebman").show();
$("#choiceaman").hide();
$("#pilotman").hide();




else
$("#pilotvrouw").hide();
$("#pilotman").hide();
$("#choiceavrouw").hide();
$("#choiceaman").hide();
$("#choicebvrouw").hide();
$("#choicebman").hide();

);









share|improve this question
















I'm making an interactive series for my school project. We have some voice overs on the video's. So we have male and female voices. So I made a page with a button where they can choose between a male (man) and female(vrouw). the first if statement works like a charm. ( choosing between a male and female voice) after this, the user can choose between 2 choices in the video. But "choiceaman" doesn't work at all. Anyone an idea how I can make it work better. (FYI I'm not a coder usually so this is all new for me)



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man")
$("#pilotman").show();
$("#pilotvrouw").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#keuzemanvrouw").hide();


else if ($.cookie('keuzemanvrouw') == "vrouw")
$("#pilotvrouw").show();
$("#pilotman").hide();
$("#choiceaman").hide();
$("#choicebman").hide();
$("#choiceavrouw").hide();
$("#choicebvrouw").hide();
$("#keuzemanvrouw").hide();

else if ($.cookie('choice1') == "choiceaman")
$("#choiceaman").show();
$("#choicebman").hide();
$("#pilotman").hide();


else if ($.cookie('choice1') == "choiceavrouw")
$("#choiceavrouw").show();
$("#choicebvrouw").hide();
$("#pilotvrouw").hide();



else if ($.cookie('choice1') == "choiceman")
$("#choicebman").show();
$("#choiceaman").hide();
$("#pilotman").hide();




else
$("#pilotvrouw").hide();
$("#pilotman").hide();
$("#choiceavrouw").hide();
$("#choiceaman").hide();
$("#choicebvrouw").hide();
$("#choicebman").hide();

);






javascript if-statement






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 10:26









Koen Hollander

98521529




98521529










asked Nov 13 '18 at 10:21









Tim RoeringTim Roering

165




165












  • @PaulCrovella this is the script running on the page

    – Tim Roering
    Nov 13 '18 at 10:26











  • @TimRoering and it has nothing to do with PHP :)

    – Fyntasia
    Nov 13 '18 at 10:26











  • After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

    – yasoh
    Nov 13 '18 at 10:26











  • thats jquerry, right?:o

    – Leo Tahk
    Nov 13 '18 at 10:27











  • Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

    – Alive to Die
    Nov 13 '18 at 10:31

















  • @PaulCrovella this is the script running on the page

    – Tim Roering
    Nov 13 '18 at 10:26











  • @TimRoering and it has nothing to do with PHP :)

    – Fyntasia
    Nov 13 '18 at 10:26











  • After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

    – yasoh
    Nov 13 '18 at 10:26











  • thats jquerry, right?:o

    – Leo Tahk
    Nov 13 '18 at 10:27











  • Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

    – Alive to Die
    Nov 13 '18 at 10:31
















@PaulCrovella this is the script running on the page

– Tim Roering
Nov 13 '18 at 10:26





@PaulCrovella this is the script running on the page

– Tim Roering
Nov 13 '18 at 10:26













@TimRoering and it has nothing to do with PHP :)

– Fyntasia
Nov 13 '18 at 10:26





@TimRoering and it has nothing to do with PHP :)

– Fyntasia
Nov 13 '18 at 10:26













After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

– yasoh
Nov 13 '18 at 10:26





After choosing between Men or Women your if sentece stops, so for choice1 cookie create a new if sentence.

– yasoh
Nov 13 '18 at 10:26













thats jquerry, right?:o

– Leo Tahk
Nov 13 '18 at 10:27





thats jquerry, right?:o

– Leo Tahk
Nov 13 '18 at 10:27













Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

– Alive to Die
Nov 13 '18 at 10:31





Use common class like man,vrouw...... instead of multiple id's and then do the if-else.code will become short and more readable

– Alive to Die
Nov 13 '18 at 10:31












1 Answer
1






active

oldest

votes


















1














Try this instead:



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man" );


Your if statements are all hanging off each other, so the choice1 cookie else ifs won't run if keuzemanvrouw is man or vrouw. else ifs only run if there are no other previous if statements that fired.



Think of it like this:



if (false) // Does check this statement.
// Doesn't run this code.
else if (true) // Does check this statement.
// Runs this code.
else if (true) // Doesn't check this statement, because the previous one worked.
// Doesn't run this code.






share|improve this answer























  • Worked like a charm! thanks allot! :)

    – Tim Roering
    Nov 13 '18 at 10:34











  • No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

    – Davіd
    Nov 13 '18 at 10:35












  • Already tried to accept it but can't for another minute haha :)

    – Tim Roering
    Nov 13 '18 at 10:36











  • @TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

    – Davіd
    Nov 13 '18 at 10:37










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278790%2fgetting-multiple-if-statements%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Try this instead:



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man" );


Your if statements are all hanging off each other, so the choice1 cookie else ifs won't run if keuzemanvrouw is man or vrouw. else ifs only run if there are no other previous if statements that fired.



Think of it like this:



if (false) // Does check this statement.
// Doesn't run this code.
else if (true) // Does check this statement.
// Runs this code.
else if (true) // Doesn't check this statement, because the previous one worked.
// Doesn't run this code.






share|improve this answer























  • Worked like a charm! thanks allot! :)

    – Tim Roering
    Nov 13 '18 at 10:34











  • No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

    – Davіd
    Nov 13 '18 at 10:35












  • Already tried to accept it but can't for another minute haha :)

    – Tim Roering
    Nov 13 '18 at 10:36











  • @TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

    – Davіd
    Nov 13 '18 at 10:37















1














Try this instead:



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man" );


Your if statements are all hanging off each other, so the choice1 cookie else ifs won't run if keuzemanvrouw is man or vrouw. else ifs only run if there are no other previous if statements that fired.



Think of it like this:



if (false) // Does check this statement.
// Doesn't run this code.
else if (true) // Does check this statement.
// Runs this code.
else if (true) // Doesn't check this statement, because the previous one worked.
// Doesn't run this code.






share|improve this answer























  • Worked like a charm! thanks allot! :)

    – Tim Roering
    Nov 13 '18 at 10:34











  • No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

    – Davіd
    Nov 13 '18 at 10:35












  • Already tried to accept it but can't for another minute haha :)

    – Tim Roering
    Nov 13 '18 at 10:36











  • @TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

    – Davіd
    Nov 13 '18 at 10:37













1












1








1







Try this instead:



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man" );


Your if statements are all hanging off each other, so the choice1 cookie else ifs won't run if keuzemanvrouw is man or vrouw. else ifs only run if there are no other previous if statements that fired.



Think of it like this:



if (false) // Does check this statement.
// Doesn't run this code.
else if (true) // Does check this statement.
// Runs this code.
else if (true) // Doesn't check this statement, because the previous one worked.
// Doesn't run this code.






share|improve this answer













Try this instead:



$(document).ready(function() 
if ($.cookie('keuzemanvrouw') == "man" );


Your if statements are all hanging off each other, so the choice1 cookie else ifs won't run if keuzemanvrouw is man or vrouw. else ifs only run if there are no other previous if statements that fired.



Think of it like this:



if (false) // Does check this statement.
// Doesn't run this code.
else if (true) // Does check this statement.
// Runs this code.
else if (true) // Doesn't check this statement, because the previous one worked.
// Doesn't run this code.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 10:27









DavіdDavіd

3,62541635




3,62541635












  • Worked like a charm! thanks allot! :)

    – Tim Roering
    Nov 13 '18 at 10:34











  • No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

    – Davіd
    Nov 13 '18 at 10:35












  • Already tried to accept it but can't for another minute haha :)

    – Tim Roering
    Nov 13 '18 at 10:36











  • @TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

    – Davіd
    Nov 13 '18 at 10:37

















  • Worked like a charm! thanks allot! :)

    – Tim Roering
    Nov 13 '18 at 10:34











  • No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

    – Davіd
    Nov 13 '18 at 10:35












  • Already tried to accept it but can't for another minute haha :)

    – Tim Roering
    Nov 13 '18 at 10:36











  • @TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

    – Davіd
    Nov 13 '18 at 10:37
















Worked like a charm! thanks allot! :)

– Tim Roering
Nov 13 '18 at 10:34





Worked like a charm! thanks allot! :)

– Tim Roering
Nov 13 '18 at 10:34













No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

– Davіd
Nov 13 '18 at 10:35






No problem @TimRoering , happy to help :) Be sure to read this wiki page on what to do when someone answers your question.

– Davіd
Nov 13 '18 at 10:35














Already tried to accept it but can't for another minute haha :)

– Tim Roering
Nov 13 '18 at 10:36





Already tried to accept it but can't for another minute haha :)

– Tim Roering
Nov 13 '18 at 10:36













@TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

– Davіd
Nov 13 '18 at 10:37





@TimRoering Haha, that's alright :) Although you do have the voting privilege now, so be sure to try that out ;)

– Davіd
Nov 13 '18 at 10:37

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278790%2fgetting-multiple-if-statements%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto