Storing the clicked value in radio buttonswith cookies

<>

This question is an exact duplicate of:

Answers


You need to set AND get the cookie.

FIDDLE

function setCookie(name, value, days) { // from http://www.quirksmode.org/js/cookies.html
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    } else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

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

window.onload = function () {
    var gender = getCookie('samplecookie');
    if (gender) {
        if (gender=="male") document.getElementById('male').click(); // or .checked=true; 
        else if (gender=="female") document.getElementById('female').click();
    }
    document.getElementById('buttons').onclick = function () {
        var m = document.getElementById('male');
        var f = document.getElementById('female');
        if (m.checked) {
            setCookie('samplecookie', m.value, 30);
        } else if (f.checked) {
            setCookie('samplecookie', f.value, 30);
        }
    }

}

Need Your Help

C pthread programming(counting prime numbers) using mutex_lock, cond_wait

c pthreads

i want to make a programme that counts the number of prime between certain numbers.

Append form partial in the new view of the same model in rails

ruby-on-rails forms view model

i'd like to use the same model to create in one view (new.erb.html) more records at once with a single submit.