How to create controls using javascript


How to create controls using javascript

Just drag and drop one button control to page.
just call CreateTextbox() onclick event of that button control.
In runtime if you click button the dynamic controls will display


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

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

<html>
<head>
<title>Dynamic Form</title>
<script type="text/javascript" >
function CreateTextbox()
{
var i = 1;
createTextbox.innerHTML = createTextbox.innerHTML +"<input type=text name='mytext'+ i/>"
createTextbox.innerHTML = createTextbox.innerHTML +"<input type=button value='Dynamci Button'+ i name='mytext'+ i/>"

}
</script>
</head>
<body>

<form name="form">
<input type="button" value="clickHere" onClick="CreateTextbox()"/>
<div id="createTextbox">

</div>
</form>
</body>
</html>


Related Articles

More articles: Create controls JavaScript create controls Dynamically add controls

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: