1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

cookies checkboxes what am i doing wrong

Discussion in 'Software Development' started by frag123456, Dec 5, 2002.

Thread Status:
Not open for further replies.
  1. frag123456

    frag123456 Thread Starter

    Joined:
    Dec 5, 2002
    Messages:
    1
    ok here it goes


    i was wondering what i ma doing wrong i keep getting this in my debugger.

    document.all has no properties....

    do i need to change the way i reference my checkboxs?

    heres the code any help would be greatly appreciated


    var chk0 = false;
    var chk1 = false;
    var chk2 = false;
    var chk3 = false;
    var chk4 = false;
    var chk5 = false;
    var chk6 = false;
    var chk7 = false;
    var chk8 = false;
    var chk9 = false;
    var chk10 = false;


    var storedVals;

    function GetCookie(sName)
    {
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie.split("=");
    if (sName == aCrumb[0])
    return unescape(aCrumb[1]);
    }

    // a cookie with the requested name does not exist
    return null;
    }

    function setCookie(cookieName, item, exMin)
    {
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (exMin * 60 * 1000));
    document.cookie = cookieName + " = " + item + ";path=/;expires = " + expdate.toGMTString();
    alert(item);
    }

    function setChecks()
    {
    if(storedVals != null)
    {
    var chkVals = storedVals.split(',');
    chk0 = chkVals[0];
    chk1 = chkVals[1];
    chk2 = chkVals[2];
    chk3 = chkVals[3];
    chk4 = chkVals[4];
    chk5 = chkVals[5];
    chk6 = chkVals[6];
    chk7 = chkVals[7];
    chk8 = chkVals[8];
    chk9 = chkVals[9];
    chk10 = chkVals[10];
    }

    document.for[0].checked = chk0;
    document.all['w'].checked = chk1;
    document.all['e'].checked = chk2;
    document.all['r'].checked = chk3;
    document.all['t'].checked = chk4;
    document.all['y'].checked = chk5;
    document.all['u'].checked = chk6;
    document.all['i'].checked = chk7;
    document.all['o'].checked = chk8;
    document.all['p'].checked = chk9;
    document.all['a'].checked = chk10;

    }

    function saveChanges()
    {
    setCookie('checks',((chk0)?1:0) + ',' + ((chk1)?1:0) + ',' + ((chk2)?1:0) + ',' + ((chk3)?1:0) + ',' + ((chk4)?1:0) + ',' + ((chk5)?1:0) + ',' + ((chk6)?1:0) + ',' + ((chk7)?1:0) + ',' + ((chk8)?1:0) + ',' + ((chk9)?1:0) + ',' + ((chk10)?1:0),5);
    }

    function initialize()
    {
    storedVals = GetCookie('checks');
    setChecks();
    }
    </SCRIPT>
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/107025

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice