autofill and select formfields for debugging


/ Published in: JavaScript
Save to your folder(s)

when testing forms you don't always want to fill in dummydate
this is a function i used to autofill and select values.


Copy this code and paste it in your HTML
  1. function dummyreg() {
  2. var currentTime = Date.parse(new Date());
  3.  
  4. document.getElementById("nickname").value = "dummynick" + currentTime;
  5. document.getElementById("checkbox").checked = true; // checkbox
  6. document.getElementById("radiobutton").checked = true; // radiobutton
  7. document.getElementById("pulldown").selectedIndex = 2; // dropdown
  8.  
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.