[thelist] Javascript bookmarklet to populate fields takes me to new page — why?

Barney Carroll barney at clickwork.net
Wed Sep 23 03:58:29 CDT 2009


Hi folks,

For a while now I've been working on an ecommerce web application whose
content is largely arrived at by the filling in of large forms. As a way of
saving valuable time I want to write javascript: bookmarklets which will
populate the various forms with different content to make it easier to test
a wide variety of permutations.

So the bookmarklet so far is pretty much as follows:

javascript:document.getElementById('productDescriptor1').value='this';document.getElementById('productDescriptor2').value='that';

I don't want to submit, or take any real action apart from pure
pre-population, so forcing values is really all I want to do.

When I enter this into the address bar and hit enter, the resulting
behaviour is problematic:

   1. Only the last command takes effect. For the script above, only
   productDescriptor2 gets 'that' assigned to it.
   2. Immediately after the DOM script takes effect, I am given a document
   whose only content is the last value I assigned. Just a blank page with
   unformatted 'that', and the page I had been scripting for in my immediate
   history.


Does anybody know what this might be about, and how I can get the script to
behave as I'd expect?


Regards,
Barney Carroll

barney.carroll at gmail.com
07594 506 381



More information about the thelist mailing list