Seattle Web Design Seattle Web Design

Simple JavaScript Code

This is how you can make a very simple form and play with it by using onclick attribute. 

 

<!DOCTYPE html>
  <html>
  <head>
  <title>Playing around with Forms</title>
  <meta charset="windows-1252">
  <script>
   
  // make a function
  function fred() {
  window.alert("hi " + document.oneb.name.value);
  document.oneb.name.value = "";
  }
   
  function cb() {
  var type;
  if(document.oneb.unmask.checked) {
  type = 'text';
  } else {
  type = 'password';
  }
  document.oneb.pwd.type = type;
  }
   
  </script>
  </head>
  <body onload="cb();">
  <h1 id='title' onclick='style.display="none";'>Playing around with Forms</h1>
  <form name="oneb">
  Name: <input type="text" name="name" value='bob'><br>
  Age: <input type='text' name='age' value='99'><br>
  Email: <input type='text' name='email' value='rh@gmail.com'><br>
  Password: <input type='password' name='pwd' value='xyzzy'>
  Unmask <input type='checkbox' name='unmask' onclick='cb();'><br/>
  <input type='submit'>
  <input type='button' value='Checking'
  onclick='fred()'>
  <input type='button' value='Come back'
  onclick='document.getElementById("title").style.display = "block";'>
  </form>
  </body>
  </html>




Leave a Reply

 
Kianoush Facebook Profile Kianoush Google Plus Profile Kianoush LinkedIn Profile Find Kianoush Twitter