javascript - translate a variable amount of input values into a select -


var namelist = editnamebox.children.value; (var f = 0; f < namelist.length; f += 1) {             slotname.innerhtml = '<optgroup><option>' + namelist[f] + '</option></optgroup>'; } 

editnamebox div containing avariable number of inputs want generate value of each editnamebox input option.

the code above no work, tried namelist[f].value instead of in namelist var not run. wrong here?

full page: http://powerpoint.azurewebsites.net/ set timeslot. "undefined" should content of empty text fields above

you should build string loop , update innerhtml. (assuming other portions correct without seeing markup)

var namelist = editnamebox.children,     slotnamehtml = '';  //build html string (var f = 0; f < namelist.length; f += 1) {      slotnamehtml += '<optgroup><option>'                         + namelist[f].value                         + '</option></optgroup>'; }  slotname.innerhtml = slotnamehtml; //update html 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -