I have a html table built from a DB. It has a "Edit" button that will open up a form.
One of those input types will be a radio button I want to generate with On/Off selection:
<input type="radio" name="camera_status" value="On" /> On<br />
<input type="radio" name="camera_status" value="Off" /> Off
I have 3 problems:
I don't know how to create multiple radio options. The code below only creates one.
How do I make the value I passed in "camerastatus" the default checked value?
I need to have multiple labels. The form will be "Camera status" then labels for On/Off.
Code:
function edit2(to, cameraname, cameraquality, camerastatus, emailnotice, camerahash)
{
var mydiv = document.getElementById("editform");
var myForm = document.createElement("form");
myForm.method = "post";
myForm.action = to;
//camera_status
label = document.createElement("label");
label.for = "text";
label.innerHTML="<br>Camera status: <br>";
myForm.appendChild(label);
var myRadioElement;
try{
myRadioElement = document.createElement('<input type="radio" name="camera_status" />On');
}catch(err){
myRadioElement = document.createElement('input');
}
myRadioElement.type = "radio";
myRadioElement.name = "camera_status";
myForm.appendChild(myRadioElement);
mydiv.appendChild(myForm);
}