I am trying to add few items to a list box from a text box using javascript. but the problem is as soon as I am adding the items, it gets visible in the list box for a second and then gets deleted. Any solution for this?
I am adding items from TextBox4 to ListBox1
function AddToList() {
// Create an Option object
var opt = document.createElement("option");
// Add an Option object to List Box
document.getElementById("ListBox1").options.add(opt);
opt.text = document.getElementById("TextBox4").value;
opt.value = document.getElementById("TextBox4").value;
document.getElementById("ListBox1").options.add(opt);
}
Got the solution, Need to add
return false;
at the end of the function.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句