How do i display an alert box showing "The value already exists" when an existing option is added to the dropdown list box from a text box?
Alert box, Drop down list, Text box
Collapse
X
-
-
Hello,
The code i have created is as follows.I need to include a statement to display an alert box showing "the value already exists" , when an existing option is added to dropdown list box from a text box.
Regards,Code:<html> <script type= "text/javascript" language="javascript"> function addition() { var textb= document.getElementById("txtCombo"); var combo= document.getElementById("combo"); var option= document.createElement("option"); option.text= textb.value; option.value= textb.value; combo.add(option); } </script> <body> <form> location <select name="combo" id="combo" > <option>ooty <option>kodai <option>chennai </select> <input type="text" name="txtCombo" id="txtCombo"> <input type="button" value="add" onclick="addition()"> </form> </body> </html>
ShravsComment
Comment