Getting multiple if statements
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
add a comment |
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
@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 likeman,vrouw......
instead of multipleid's
and then do theif-else
.code will become short and more readable
– Alive to Die
Nov 13 '18 at 10:31
add a comment |
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
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
javascript if-statement
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 likeman,vrouw......
instead of multipleid's
and then do theif-else
.code will become short and more readable
– Alive to Die
Nov 13 '18 at 10:31
add a comment |
@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 likeman,vrouw......
instead of multipleid's
and then do theif-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
add a comment |
1 Answer
1
active
oldest
votes
Try this instead:
$(document).ready(function()
if ($.cookie('keuzemanvrouw') == "man" );
Your if
statements are all hanging off each other, so the choice1
cookie else if
s won't run if keuzemanvrouw
is man
or vrouw
. else if
s 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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Try this instead:
$(document).ready(function()
if ($.cookie('keuzemanvrouw') == "man" );
Your if
statements are all hanging off each other, so the choice1
cookie else if
s won't run if keuzemanvrouw
is man
or vrouw
. else if
s 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.
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
add a comment |
Try this instead:
$(document).ready(function()
if ($.cookie('keuzemanvrouw') == "man" );
Your if
statements are all hanging off each other, so the choice1
cookie else if
s won't run if keuzemanvrouw
is man
or vrouw
. else if
s 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.
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
add a comment |
Try this instead:
$(document).ready(function()
if ($.cookie('keuzemanvrouw') == "man" );
Your if
statements are all hanging off each other, so the choice1
cookie else if
s won't run if keuzemanvrouw
is man
or vrouw
. else if
s 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.
Try this instead:
$(document).ready(function()
if ($.cookie('keuzemanvrouw') == "man" );
Your if
statements are all hanging off each other, so the choice1
cookie else if
s won't run if keuzemanvrouw
is man
or vrouw
. else if
s 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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
@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 multipleid's
and then do theif-else
.code will become short and more readable– Alive to Die
Nov 13 '18 at 10:31