Skip to content Skip to sidebar Skip to footer

Pass Radiobutton Value From One Html Page To Another As Parameter And Extract It On Next Html Page

I am new to HTML. I have written below code to select from one of the option. After selecting one of the radiobutton and clicking the submit button, user should get redirected to e

Solution 1:

You can use either Cookies or LocalStorage, where the LocalStorage is easier to implement, but requires the latest browser, and users may disable cookies for privacy reasons.

Cookies

functionsetCookie(name, value, days) {
    if (days) {
        var date = newDate();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    elsevar expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

functiongetCookie(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);
    }
    returnnull;
}

// First PagesetCookie("myinputvalue", document.getElementsByName("candidateType")[0].value, 10);

// Second PagegetCookie("myinputvalue");

LocalStorage

if (typeof(Storage) !== "undefined") {
  // First PagelocalStorage.setItem("myinputvalue", document.getElementsByName("candidateType")[0].value);
  // Second PagelocalStorage.getItem("myinputvalue");
} else {
  // Sorry! No Web Storage support..// Use the above cookie method.
}

Post a Comment for "Pass Radiobutton Value From One Html Page To Another As Parameter And Extract It On Next Html Page"