shravanti88
03-20-2010, 04:23 AM
Hi,
I have a form that includes dropdown box, text box and add button.when a value is entered in the text box and the add button is clicked, it will added to the dropdown box. I need to create an alert message displaying "the value already exists" when an existing option is entered in the textbox.
The code i have created is as follows.Now i need to include a statement within the function to display an alert message.
[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>[code]
Thanks,
Regards,
Shravs
I have a form that includes dropdown box, text box and add button.when a value is entered in the text box and the add button is clicked, it will added to the dropdown box. I need to create an alert message displaying "the value already exists" when an existing option is entered in the textbox.
The code i have created is as follows.Now i need to include a statement within the function to display an alert message.
[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>[code]
Thanks,
Regards,
Shravs