Wednesday 4 February 2015

Create an HTML form to print contents of a form on the HTML page using JavaScript.

  1. <html>
  2. <head>
  3. <title>form tag</title>
  4. <script type="text/javascript">
  5. function color(){
  6. var txtsubobj=document.getElementById("txtFN");
  7. var selobj=document.getElementById("sel"); 
  8. var divtestobj = document.getElementById("divtest");
  9. divtestobj.innerHTML = selobj.options.length;
  10. }
  11. </script>
  12. </head>
  13. <body id="body">
  14. <table id="table" style="border:5px;background-color:grey;margin-left:400px;margin-top:250px;">
  15. <tr><th>form tag</th></tr>
  16. <tr><td><form id="form">
  17. first name:<input id="txtFN" type="text" value="" name="fname"></input><br/><br/>
  18. last name :<input id="txtLN" type="text"value="" name="sname">
  19. <select id="sel">
  20. <option value="volvo">Volvo</option>
  21. <option value="saab">Saab</option>
  22. <option value="mercedes">Mercedes</option>
  23. <option value="audi">Audi</option>
  24. </select>
  25. </input><br/>
  26. <br/>
  27. <input id="txtradm" type="radio" name="sex">male</input>
  28. <input id="txtradf" type="radio" name="sex">female</input><br/>
  29. <input id="txtcbox" type="checkbox" checked="checked">sure</input><br/>
  30. <textarea rows="4" cols="50">
  31. http://prashantanandjha.blogspot.in/. 
  32. </textarea>
  33. <input id="txtsub" onclick="color();" type="submit" name="submit"></input>
  34. <div id="divtest">
  35. </div>
  36. </td></tr> 
  37. </table>
  38. </form>
  39. </body>
  40. </html>

No comments:

Post a Comment