Home > front end >  This incremental form to do?
This incremental form to do?

Time:09-20

Drop-down form to choose a few, is automatically a few form

But, pop-up form field is different, the pop-up form fields is aaa, BBB, CCC and DDD, eee

CodePudding user response:

 


; (function () {
Var sel=document. GetElementById (" sel ");
The function change () {
Var index=sel. SelectedIndex;
Var children=document. QuerySelectorAll (" # inputBox> Div ");
Var len=Math. Max (index + 1 and the children. Length);
for (var i=0; i If (I & gt; The index) {
The children [I]. Style. The display="none";
} else if (I & lt; Children. Length) {
The children [I]. Style. The display="block";
} else {
Var div=document. The createElement method (" div ");
Div. InnerHTML=sel. Options [I] text + '& lt; Input type="text" name="' + sel. Options [I] value + '"/& gt; ';
Document. The getElementById (" inputBox "). The appendChild (div);
}
}
}
Sel. Onchange=change;
Change ();
}) ();
</script>
  • Related