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

  • Home
  • SEARCH
  • 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 8353481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:16:24+00:00 2026-06-09T09:16:24+00:00

function changesex(){ var cookie=document.cookie; var sex; //alert(cookie); cooarr=cookie.split(;); for (var i=0;i<cooarr.length;i++){ coo=cooarr[i].split(=); if (coo[0]==sex){

  • 0
function changesex(){
    var cookie=document.cookie;
    var sex;
    //alert(cookie);
    cooarr=cookie.split(";");
    for (var i=0;i<cooarr.length;i++){
        coo=cooarr[i].split("=");
        if (coo[0]=="sex"){
            sex=coo[1];
            break;
        }
    }
    if (sex=="male") sex="famale";
    else sex="male";
    var date=new Date();
    date.setTime(date.getTime()+3600*24*30);
    document.cookie="sex="+sex+";expires="+date.toGMTString();
    return sex;
}

this javascript function is used to change a cookie content,but I find a problem that this expression
if (coo[0]==”sex”){
can be true only if i==0 and coo[0] equals the following string.
so the problem is the if expression can’t be true even if coo[0] equals “xxx” string.
I spent a couple of hours on this and I was confused.

  • 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-06-09T09:16:26+00:00Added an answer on June 9, 2026 at 9:16 am

    I got the answer when we got document.cookie and split by “;”,their happen to be a space in front of the cookie name string,for example “sex” will become ” sex”,I don’t know the exactly reason but I can’t handle cookie now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: <script type=text/javascript> function changeText(elem){ var oldHTML = document.getElementById(elem).innerHTML; var
I have this piece of code var f = function() { this.x = 100;
I have this jquery script: $('[id^=changesetList] tr').each(function () { var sid = $(this).attr('sid'); $(this).find('td
In my responder I have: Spanish.ADDWORD = SC.Responder.create({ didBecomeFirstResponder: function(responder) { var store =
how is that possible that call to the alert function changes behavior of a
I have a function that changes a dom element's text to a given value,
i make navigation function that changes navigation default image to hover image. default image
I have a javascript function that changes the innerHtml of a <div> tag to
I've written a function that changes the css positioning of a div I've been
I'm using the following function that changes a calendar selection at a set time

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.