My requirement is on click of a button i have to add <select> control with some options like <option>text<option>. with following code i am able add a select control but i am not able add an <option> to it. every time the button click i want to add a new <select> control. my script is like function AddSelect() { var tbody = document.getElementById("DefautlTable").getElementsByTagName("TBODY")[0]; var row = document.createElement("TR"); var td1 = document.createElement("TD");
Hi Vishnu, you can use this function, to add a new option to a selectbox: function addOption() { // create a new option myEntry = new Option('myText','myValue',false,true); // the parameters for new options: // 1. diplayed text for option // 2. value for option (optional) // 3. defaultSelected = true/false (optional) // 4. selected = true/false (optional) // paste it on the end of my selectbox document.myform.mySelect.options[document.myform.mySelect.length] = myEntry;
} This one should work. maybe there's a typo somewhere regards Christoph