Getting the value of the selected switch
$("#poll1p").append("<input type='radio' name='radio1' id='r1' /><label for='radio1'>"+x[0]+"</label><br>");
$("#poll1p").append("<input type='radio' name='radio1' id='r2' /><label for='radio1'>"+x[1]+"</label><br>");
the values x[0]and x[1]are the values of the array. I cannot get the selected switch value with
$("input:radio[name='radio1']:checked").val();
If I use the above, I just get "ON" as the return value ... I need a value from
You need to specify an attribute value="..."for your switches if you want to return some value other than "on".
Use the following and you must return to 1or 2from .val():
<input type='radio' name='radio1' id='r1' value="1" />
<input type='radio' name='radio1' id='r2' value="2" />
Not relevant, but you also need to use for="r1"it for="r2"for your tables too - i.e. use an element idas the attribute value of forits label.