Wednesday, August 16th, 2017

Append a data at the end of html select tag

0

Append a data at the end of html select tag

//append at the end of select

function addKeyword()
{
var k = document.getElementById(“word”).value;//get the data from a text filed
var elOptNew = document.createElement(‘option’);
elOptNew.text = k ;
elOptNew.value = k ;
var elSel = document.getElementById(“words”);//words is the html select control id
try {
elSel.add(elOptNew, null); // standards compliant; doesn’t work in IE
}
catch(ex) {
elSel.add(elOptNew, elSel.selectedIndex); // IE only
}
}

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • RSS
  • Technorati
  • Twitter

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Secure Linux Web Hosting