»
EnglishFrenchVietnamese

Print - Autofill and Select Form Fields - JavaScriptBank.com

Full version: jsB@nk » Form » Autofill and Select Form Fields
URL: https://www.javascriptbank.com/autofill-and-select-form-fields.html

Autofill and Select Form Fields © JavaScriptBank.comWhen testing forms you don't need to keep filling in the different fields. Use this function to automatically fill-in input blocks and select values in the form for you. Very easy to use.

Full version: jsB@nk » Form » Autofill and Select Form Fields
URL: https://www.javascriptbank.com/autofill-and-select-form-fields.html



JavaScript
<script language="javascript"><!--// Created by: assbach :: http://www.ipernity.com/home/assbachfunction dummyreg() {  var currentDate = new Date();  var month = currentDate.getMonth() +1;  var day = currentDate.getDate();  var year = currentDate.getFullYear();  var formDate = month + "-" + day + "-" + year;  // Use whatever data you like for the items below document.getElementById("name").value = "JavaScriptBank.com"; document.getElementById("email").value = "email@JavaScriptBank.com"; document.getElementById("datebox").value = formDate; document.getElementById("checkbox").checked = true; // checkbox document.getElementById("radiobutton").checked = true; // radiobutton document.getElementById("pulldown").selectedIndex = 1; // dropdown}// Multiple onload function created by: Simon Willison// http://simonwillison.net/2004/May/26/addLoadEvent/function addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}addLoadEvent(function() {  dummyreg();});//--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form>  <table>    <tbody><tr>      <td>Name:</td>      <td><input class="inputBox" id="name" type="text"></td>    </tr><tr>      <td>E-mail:</td><td><input class="inputBox" id="email" type="text"></td>    </tr><tr>      <td>Date</td><td><input class="date" id="datebox" type="text"></td>    </tr><tr>      <td>        <input id="checkbox" name="option1" value="Milk" type="checkbox"> Milk<br>        <input name="option2" value="Butter" type="checkbox"> Butter<br>        <input name="option3" value="Cheese" type="checkbox"> Cheese<br>      </td>      <td>        <input name="heading of button" value="Milk" type="radio"> Milk<br>        <input id="radiobutton" name="heading of button" value="Butter" type="radio"> Butter<br>        <input name="heading of button" value="Cheese" type="radio"> Cheese      </td>    </tr>    <tr>      <td>        <select id="pulldown">          <option>Milk</option>          <option>Coffee</option>          <option>Tea</option>        </select>      </td>      <td>&nbsp;</td>    </tr>  </tbody></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->