Home > DeveloperSection > Beginner > Creating html controls using Java Script

Creating html controls using Java Script


JavaScript JavaScript 
Ratings:
0 Comment(s)
 5261  View(s)
Rate this:

Creating html controls using Java Script

In this demonstration we learn, how to create html control by using java script.

Following code snippet demonstrate to creating html controls in java script.

<script type="text/javascript">

        function createHtmlDocument() {

 

            //creating html button in hava script.

            var button1="<input type='button' value='Html Button in Java Script' id='btn1' /><br />";

            document.write(button1);

           

            //Creating html text field in java script.

            var textbox = "<input type='text' id='tt1' value='This is a text box control.' /> <br />";

            document.write(textbox);

 

            //Creating radio button by using java script.

            var rdb = "<input type='radio' name='rd' id='male' value='Male' /> <br />";

            document.write(rdb);

 

        }

</script>

At the load event of the body call this function.

<body onload="createHtmlDocument()">

   

</body>

Output of the following code snippet is as follows

Html controls using Java Script

 


Don't want to miss updates? Please click the below button!

Follow MindStick