Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:40:27+00:00 2026-05-22T21:40:27+00:00

sorry if i’m doing something monumentally stupid, but I can’t get this IF statement

  • 0

sorry if i’m doing something monumentally stupid, but I can’t get this IF statement working…

What it does is that it checks certain values from a cookie, setting combo box defaults.

Through debugging I can see that all the cookie variables are correct, however the IF statement does not seem to read the value? The first two IF’s work correctly but the last else-if does not work.

Any help much appreciated, thanks

function checkBody() {
   var cookie1 = readCookie("Text Colour");
   textCol = cookie1 ? cookie1 : "#444";

   var cookie2 = readCookie("Background Colour");
   backCol = cookie2 ? cookie2 : "white";

   var cookie3 = readCookie("Link Colour");
   linkCol = cookie3 ? cookie3 : "#0424B5";

   var cookie4 = readCookie("Heading1 Colour");
   heading1Col = cookie4 ? cookie4 : "#0424B5";

   var cookie5 = readCookie("Headings Colour");
   headingsCol = cookie5 ? cookie5 : "#99975A";

   var element = document.getElementById('colours');
   if(textCol == cookie1 && backCol == cookie2)
      element.value = "#444,white,#0424B5,#0424B5,#99975A";
   else if(textCol == cookie1 && backCol == cookie2)
      element.value = "black,yellow,black,black,black";
   else if(textCol == cookie1 && backCol == cookie2)
      element.value = "black,#87CEFA,black,black,black";

   bodyStyle(textCol,backCol,linkCol,heading1Col,headingsCol);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:40:28+00:00Added an answer on May 22, 2026 at 9:40 pm

    All the if are same. the latter two are never reached.

    ...
    else if(textCol == cookie1 && backCol == cookie2)
        element.value = "black,yellow,black,black,black";
    else if(textCol == cookie1 && backCol == cookie2)
        element.value = "black,#87CEFA,black,black,black";
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this sounds like a really stupid question, but I need to make
Sorry, but I know nothing at all about fonts, so I hope that this
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if the title is poorly descriptive, but I can't do better right now
sorry for being dumb here, but I failed to see why these tools can
Sorry about this long block of code, but I think it makes sense to
Sorry if this is a newbie question. I have searched but found nothing... Using
Sorry, lots of code coming up.. I saw another question like this that used
Sorry for the rubbish title but hopefully this will explain: Given the table name
Sorry if this is a repeat, but I've been looking for an answer to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.