JSFiddle - React, Tailwind, and code Playground

by ivan

HTML

<script type="text/javascript">
function myfunc(){
    $('#void input').each(function(id,elem){
         b = $("#res").val();
         if(b.length > 0){
            $("#res").val( b + ',' + $(this).val() );
        } else {
            $("#res").val( $(this).val() );
        }

    });
        alert("VAL "+$("#res").val());
    $("#real").submit();

return false;
}

</script>

<form id='real' method='POST' action="#">
<input id="res" type="hidden" name="parameter" value=""/>
</form>

<form method='post' id="void">
<input type="checkbox" name="option1" value="oats"> Oats
<input type="checkbox" name="option2" value="beans"> Beans
<input type="hidden" name="parameter" value="a"/>
<input type="submit" value="Submit" onClick="javascript:myfunc()"/>
</form>