<html> <head> <script type='text/javascript'> function createCheckBox(){ var checkbox = document.createElement('input'); checkbox.type = "checkbox"; checkbox.name = "name"; checkbox.value = "value"; checkbox.id = "id"; var label = document.createElement('label') label.htmlFor = "id"; label.appendChild(document.createTextNode('label'); var container = document.getElementById('checkbox_here'); container.appendChild(checkbox); container.appendChild(label); } </script> </head> <body> <input type='button' value='Create Checkbox' onClick='createCheckBox()' /> <div id="checkbox_here"></div> </body> </html>
<html> <head> <script language="Javascript"> function append() { var cb = document.createElement( "input" ); cb.type = "checkbox"; cb.id = "id"; cb.value = "test"; cb.checked = true; var text = document.createTextNode( "checkbox" ); document.getElementById( 'append' ).appendChild( text ); document.getElementById( 'append' ).appendChild( cb ); } </script> </head> <body> <p>click the button below</p> <form action="http://localhost/test.php" name="form" id="form" method="post" enctype="multipart/form-data"> <div id="append" name="append">Append here</div> <input type="button" value="append" onclick="javascript:append()" /> <input type="submit" value="submit" /> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)