Put value in cookie when radio button is clicked with jquery

I have a wordpress plugin that generates 2 radiobutton. For conformation i'd like to display the value of the last radio button clicked on the next page.

I thought i would do this with a cookie and jquery. What i've got is this:

<script type='text/javascript'>
    var verzend = $.cookie("verzend")
    $('input:radio[value="OrderWeight-0]').click(function () {
        $.cookie('verzend', 'verzenden')
    });
    $('input:radio[value="OrderWeight-1]').click(function () {
        $.cookie('verzend', 'afhalen')
    });
</script>

Unfortuanly it's not working. Can anyone point me in the right direction?

Answers


You should try with the change event, more adapted to radio input.

<script type='text/javascript'>
    var verzend = $.cookie("verzend")
    $('input:radio').on('change', function() {
        if ($(this).val() === "OrderWeight-0") {
            $.cookie('verzend', 'verzenden')
        } else {
            $.cookie('verzend', 'afhalen')
        }
    });
</script>

Need Your Help

Successive Animations with Tweenlite/Tweenmax triggered on scroll

javascript css animation tweenlite tweenmax

I am using tweenlite/tweenmax to do animations in an html file. I want to trigger animations based on scroll position (like www.onlycoin.com). However, I cannot figure out how to do a second animat...

Sample NPAPI plugin in C for Linux

c linux firefox npapi chromium

I need to make a binary plugin in C that works with both Firefox and Chromium, on Linux. Where can I find a simple example of an NPAPI plugin for Linux, written in C?