Submitting form data

sirbounty
sirbounty used Ask the Experts™
on
I'm trying to create a bookmarklet in chrome that will modify a form's input data.

One of the fields looks like this:
<input type="text" id="shipping:firstname" name="shipping[firstname]" value="John" title="First Name" maxlength="255" class="input-text required-entry" placeholder="First Name*" onchange="shipping.setSameAsBilling(false)" autocapitalize="off" autocorrect="off" oldautocomplete="remove" autocomplete="off">

Open in new window


Yet when I click my bookmark, it just pops up the new user's name in a blank page...
code is simply:
javascript:  let first = document.getElementById('shipping:firstname');  first.value='John';

Open in new window


What am I doing wrong?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Co-Founder and Chief Architect
Top Expert 2016
Commented:
Try writing it like this:

javascript:(function(){ let first = document.getElementById('shipping:firstname'); first.value = 'John';}(window.document));

Open in new window

Top Expert 2007

Author

Commented:
Thanks for the quick turnaround!
Top Expert 2007

Author

Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial