JavaScript method of making the contents of a form appear on the screen

  • 2020-06-22 23:47:23
  • OfStack

This article illustrated how JavaScript makes the contents of a form appear on the screen. Share to everybody for everybody reference. Specific implementation methods are as follows:

1. Make the content level visible


<html>
 <head>  
  <title> test </title>
  <script type="text/javascript">
   function to()
   {
   var txt=document.getElementById("txt").value;
   document.getElementById("a").innerHTML+=txt;
   }   
  </script>
 </head>
 <body>
  <div id="a"> Here it shows: </div>
  <button onclick="to();"> The input </button>
 </body>
</html>

2. Make the content appear in tabular form


<html>
 <head>  
  <title> test </title>
  <script type="text/javascript">
   function to()
   {
   var txt=document.getElementById("txt").value;
   var row=document.getElementById("ib").insertRow();
   row.align="center";
   var tt0=row.insertCell();
   tt0.innerHTML=txt;
   }   
  </script>
 </head>
 <body>
  <div id="a"></div>
  <table id="ib">
  <tr>
  <th>content</th>
  </tr>
  </table>
  <input type="text" id="txt" value="" size="30">
  <button onclick="to();"> The input </button>
 </body>
</html>

Hopefully, this article has been helpful in your javascript programming.


Related articles: