I wrote a quick function to create a set of radio buttons, three per table row. I would like some feedback about how I can shorten this bit of code using algebraic functions, or different jQuery functionality.
var arr = [ "earth", "mars", "jupiter", "saturn", "venus", "argus", "pluto", "janus", "canary", "orange", "butter pineapple", "eventual bliss"];
var obj = { one:"earth", two:"mars", three:"jupiter", four:"saturn", five:"venus" };
var start = ""; end = "";
var count = 0;
$("#radio_container").append("<table>");
$.each(arr, function(i, val) {
if(count == 3)
{
start = "<tr>";
end = "</tr>"
count= 0;
}
$("#radio_container").append(start);
$("#radio_container").append("<td><input name='finalcategory' type='radio' value='"+val+"'></input></td><td class='style3'>"+val+"</td>");
$("#radio_container").append(end);
count++;
start = "";
end = "";
});
$("#radio_container").append("</table>");
<label><input type="radio" name="foo"> You can click the text to pick</label>
\$\endgroup\$