I'm trying to add more form options depending on what you chose and then
remove the form options if the main option is deselected. The latter is what
I'm having the problem with.
I only need suggestions on the checkbox options, not the radio options.
Depending on what advice I get for the checkbox options, I can alter the code
for the radio options.
The form code is very long so I'll only post the problem area and it's
related snippets.
This code adds the options, but I need it to remove the options when the
checkbox is deselected.
Please help. Thanks.
--
Message posted via WebmasterKB.com
remove the form options if the main option is deselected. The latter is what
I'm having the problem with.
I only need suggestions on the checkbox options, not the radio options.
Depending on what advice I get for the checkbox options, I can alter the code
for the radio options.
The form code is very long so I'll only post the problem area and it's
related snippets.
Code:
function attachHandlers(){
var the_button = document.getElementById("my_button");
the_button.onclick=function(){return checkFormFields();};
var radio_sel = document.getElementById("radiochoice");
radio_sel.onclick=addRadioOpts;
var chkbox_sel = document.getElementById("checkchoice");
chkbox_sel.onclick=addCheckOpts;
}
.....
function addCheckOpts(){
var chicken_sel = document.getElementById("checkchoice");
if (chicken_sel.checked==true)
{
var newInput3 = document.createElement('input');
newInput3.type = "radio";
newInput3.id = "first_child";
newInput3.name = "choice";
newInput3.size = "2";
newInput3.className = 'textstyle';
newInput3.value = "chicken'n'pasta";
var nameText3 = document.createTextNode("chicken'n'pasta");
var newInput4 = document.createElement('input');
newInput4.type = "radio";
newInput4.id = "second_child";
newInput4.name = "choice";
newInput4.size = "2";
newInput4.className = 'textstyle';
newInput4.value = "chicken'n'potatoes";
var nameText4 = document.createTextNode("chicken'n'potatoes");
var the_box = document.getElementById("mainchkbox");
var the_cell = the_box.parentNode;
var the_break = document.createElement('br');
the_cell.insertBefore(newInput3, the_box);
the_cell.insertBefore(nameText3, the_box);
the_cell.insertBefore(newInput4, the_box);
the_cell.insertBefore(nameText4, the_box);
the_cell.insertBefore(the_break, newInput4);
the_cell.insertBefore(the_break, the_box);
the_cell.insertBefore(the_break, second_input);
}
return;
}
checkbox is deselected.
Please help. Thanks.
--
Message posted via WebmasterKB.com
Comment