Reputation: 227
Hi I have the following JSON file
{
"bazar":
{"display_name":"BazaAR:",
"name":"bazaar",
"format":"string",
"type":"checkbox",
"format":"string",
"dflt":"MarkerBased",
"values":["MarkerBased","MarkerLess"],
"isMandatory":"true"
},
"face_detection":
{ "display_name":"Face Detection:",
"name":"face",
"format":"string",
"type":"checkbox",
"dflt":"No",
"values":["Yes","No"],
"isMandatory":"true"
},
"motion_detection":
{ "display_name":"Motion Detection:",
"name":"motion",
"format":"string",
"type":"checkbox",
"dflt":"No",
"values":["Yes","No"],
"isMandatory":"true"
}
}
Now I am generating the tags in my js file using getJSON()
$.getJSON('json_input/server_settings_input.json',function(serverData)
{
$.each(serverData,function(feild)
{
if(this.type=="checkbox")
{
$('body #tabs #tabs-3 #server').append(this.display_name).append(INPUT_CHECKBOX).attr({name:this.name}).append(NEWLINE);
}
else
if(this.type=="radiobutton")
{
$('body #tabs #tabs-3 #server').append(this.display_name).append(INPUT_RADIO).attr({name:this.name}).append(NEWLINE);
}
});
$('body #tabs #tabs-3 #server').append(SUBMIT_BUTTON);
});
How do I do the radio button check?? I tried with attr("checked":"checked")but its not working.I want to have a generic function which will check for radio buttons.How do I go about it
Upvotes: 0
Views: 422
Reputation: 12368
If you are using JQuery 1.6 >
use
.attr('checked',true)
Upvotes: 2