Thursday, 21 November 2013

Design Html Page as using java script In that If you add any subject it should go in tp Combobox List.

Like:-

Add TO ComboBox:  

Combo Box: 

Ans:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function f1(a,b) {
            var txtBox = document.getElementById("txtSubject");
            var cmbBox = document.getElementById("txtCombo");
            var option = document.createElement("option");
            option.text = txtBox.value;
            option.value = txtBox.value;

            if (txtCombo.add(option, null))
             {

                 alert("hi")
            }
         }
    </script>
</head>
<body>
<div>
Add TO ComboBox:
<input type="text" id="txtSubject" value="Enter Any Subject" />
<input type="button" value="Submit" onclick="f1()"/>
</div>
<br />
<div>
Combo Box:
<select name="combo" id="txtCombo">
</select>
</div>
</body>
</html>

No comments:

Post a Comment