Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Cookie lar bilan muammo

+1 ovoz
75 marta ko‘rilgan
so‘radi 30 oktabr, 17 Jahongir Soataliyev (260 bal)
Men JavaScriptda test dasturni yozayotgan edim. "Cookie"lar bilan ishlashda muammo yuzaga keldi. Google Chrome web-brauzeri cookielarni saqlamayapti. Lekin Internet Explorer saqlayapti. Chrome sozlamalarini tekshirib ko`rdim, "cookie"lar bilan ishlashga ruxsat berilgan.
izoh qoldirdi 01 noyabr, 17 Saidolim (3,566 bal)
savol biroz tushunarsiz. Shunga iloji bo`lsa, cookie ga saqlavotgan kodingizni ham savolga tashlab bering. balki kod orqali bilsa bo`lar, nimada xato qilganingizni. Sizni monitoringiz bizga ko`rinmayapti.
izoh qoldirdi 02 noyabr, 17 Jahongir Soataliyev (260 bal)
/*<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
</head>
<body onload="showStart()">
<script type="text/javascript">
    var test1 = {savol:"1.Ismingiz nima?", a:"A. Jahongir", b:"B. Javohir", c: "C. G`ayratjon"};
    var test2 = {savol:"2.Yoshingiz nechada?", a:"A. 20", b:"B. 21", c: "C. 26"};
    var test3 = {savol:"3.Kasbingiz nima?", a:"A. Shifokor", b:"B. O`qituvchi", c: "C. Dasturchi"};
    var array = [test1, test2, test3];
    function setCookie(cname,cvalue) {
    document.cookie = cname + "=" + cvalue + ";";
}

function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

function checkCookie(i) {
    if (i == 0) {
    var user1=getCookie("fAns");
    if (user1 == "a") {
        document.getElementById("check1").checked = true;
    };
    if (user1 == "b") {
        document.getElementById("check2").checked = true;
    };
    if (user1 == "c") {
        document.getElementById("check3").checked = true;
    };
};
if (i == 1) {
    var user1=getCookie("sAns");
    if (user1 == "a") {
        document.getElementById("check1").checked = true;
    };
    if (user1 == "b") {
        document.getElementById("check2").checked = true;
    };
    if (user1 == "c") {
        document.getElementById("check3").checked = true;
    };
};
if (i == 2) {
    var user1=getCookie("tAns");
    if (user1 == "a") {
        document.getElementById("check1").checked = true;
    };
    if (user1 == "b") {
        document.getElementById("check2").checked = true;
    };
    if (user1 == "c") {
        document.getElementById("check3").checked = true;
    };
};
}
    function showTest2(i){
        var question = array[i]['savol'];
        var answerA = "<input type='checkbox' id ='check1' onchange = 'check1("+i+")'>" + array[i]['a'] + " <br>";
        var answerB = "<input type='checkbox' id ='check2' onchange = 'check2("+i+")'>" + array[i]['b'] + " <br>";
        var answerC = "<input type='checkbox' id ='check3' onchange = 'check3("+i+")'>" + array[i]['c'] + " <br>";
        document.getElementById("demo").innerHTML = question;
        document.getElementById("t1").innerHTML = answerA;
        document.getElementById("t2").innerHTML = answerB;
        document.getElementById("t3").innerHTML = answerC;
        checkCookie(i);
    }
    function showStart(){
        showTest2(0);
        checkCookie(0);
    }
    function check1(i){
        if (document.getElementById("check1").checked) {
            document.getElementById("check2").checked = false;
            document.getElementById("check3").checked = false;
            if (i == 0) {
                setCookie("fAns", "a");
            };
            if (i == 1) {
                setCookie("sAns", "a");
            };
            if (i == 2) {
                setCookie("tAns", "a");
            };
        };
    }
    function check2(i){
        if (document.getElementById("check2").checked) {
            document.getElementById("check1").checked = false;
            document.getElementById("check3").checked = false;
            if (i == 0) {
                setCookie("fAns", "b");
            };
            if (i == 1) {
                setCookie("sAns", "b");
            };
            if (i == 2) {
                setCookie("tAns", "b");
            };
        };
    }
    function check3(i){
        if (document.getElementById("check3").checked) {
            document.getElementById("check2").checked = false;
            document.getElementById("check1").checked = false;
            if (i == 0) {
                setCookie("fAns", "c");
            };
            if (i == 1) {
                setCookie("sAns", "c");
            };
            if (i == 2) {
                setCookie("tAns", "c");
            };
        };
    }
   
</script>
<p id="demo"></p>
<p id="t1"></p>
<p id="t2"></p>
<p id="t3"></p>
<p id="tr"></p>
<button onclick="showTest2(0)">1</button>
<button onclick="showTest2(1)">2</button>
<button onclick="showTest2(2)">3</button>
</body>
</html>*/

Iltimos, saytga kiring yoki ro‘yxatdan o‘ting va shunda ushbu savolga javob berishingiz mumkin bo‘ladi.

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...