DOM elements
Dynamically using our JAVASCRIPT
JAVASCRIPT

function AddItem()
{
// Create an Option object

var opt = document.createElement(‘option’);

// Add an Option object to Drop Down/List Box
document.getElementById(“DropDownList”).options.add(opt);
var Text =prompt(“Enter Your Name”);

var Value =’addingsongs.php’
var Name = ‘data’;

// Assign text and value to Option object
opt.text = Text;
opt.setAttribute(‘name’, Name);
opt.value = Value;

}

HTML CODE

<select id=”DropDownList” name=”selectbox” >

</select>

<input type=”button” onClick=”AddItem()” value=”tutorialz.tk” />


The above code actually means that there is a select box and a button in our HTML page.When we click our button the fuction Additem()is called and a prompt box appears, give the name as you wish and that name is dynamically added to our select box simple……ANY QUERIES MAIL ME

Leave a Reply

Your email address will not be published. Required fields are marked *