Yesterday I had to type a value in some textboxes in a web application. It was time for a Greasemonkey script. The stripped version of it is:

var valButton = document.createElement("input");
valButton.type = "text";
valButton.value = "10";
var btn = document.createElement("BUTTON");
var t = document.createTextNode("POPULATE");
btn.addEventListener('click', function(){
var x = document.getElementsByClassName("dxeEditArea");
var i;
for (i=0; i< x.length; i++)

So what’s the valButton.value in line 13 since it is “10” in line 3? What line 3 actually does is not setting THE value but the default value. Actually, the user may have changed it before the onClick event.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s