Log in

No account? Create an account
Chaz Meyers [entries|archive|friends|userinfo]
Chaz Meyers

[ website | chazmeyers.com ]
[ profile | view profile ]
[ archive | view archive ]

[Links:| chazmeyers.com Twitter ]

Bookmarklet to fill in forms with prototype.js. [Sep. 18th, 2007|07:39 pm]
Chaz Meyers
[Tags|, , , , , , ]

Lately I have had to make too many forms with too many fields. I got angry at the prospect of filling in yet another form with dummy data, so I created a bookmarklet to fill the forms in with garbage.

I've only used this in firefox, and it assumes that prototype.js is loaded on the page you're using. Furthermore, it only fills in textarea, input text, and radios. Very niche! I just am putting it up here because otherwise I'll lose it and have to spend 10 minutes of my life writing this code again.

javascript:$$("input[type=text], textarea").each(function(f){ f.value = f.name + " random value"}); $$("input[type=radio], input[type=checkbox").each(function(f) { f.checked = true }); undefined

Similarly, here's a bookmarklet to clear forms:
javascript:$$("input[type=text], textarea").each(function(f){ f.value = ""}); $$("input[type=radio], input[type=checkbox").each(function(f) { f.checked = false }); undefined