Using variable value as 'name identifier' javascript/html -
i have function in javascript adds rows html table when called. in row, 1 of additions radio checkbox, allows 1 box checked every radio under same 'name'. reason, each time function called add row, 'name' attribute must change.
var namedata = "daynight" + rowcount; //irrelevant intermediary code. creates new row , cell. then: newcell.innerhtml = '<input type="radio" name=namedata value="am">'; //and newcell.innerhtml = '<input type="radio" name=namedata value="pm" checked>';
i tried (and few other variations) 'name' option, every time click button add row, every addition goes under same name (so 1 box can checked in newly created rows, instead of each row individually).
namedata
contain desired name plus row number, insuring each 'name' different.
how 'name' attribute of 'input' receive value of 'namedata'? , fix problem?
try this:
var namedata = "daynight" + rowcount; newcell.innerhtml = '<input type="radio" name="' + namedata + '" value="pm" checked>';
Comments
Post a Comment