views:

81

answers:

1

I have this line on a website

<input type="text" autocomplete="off" value="" maxlength="20" class="shipBox" name="firstName" id="firstName">

and I want my greasemonkey to automatically fill this...

I'm trying this but had no success

document.getElementById("firstName").setAttribute("autocomplete", "on");
document.getElementById("firstName").value = "Bruno"
+2  A: 

What you're doing is basically the correct way.

The usual reaqson for this not working is a second element with the same ID somewhere in the document.

By the way, setAttribute is not the recommended way of setting an attribute in HTML, as I've been reminded today. A simple ...getElementById("firstName").autocomplete = 'on' will do.

Pekka
I've changed the autocomplete and still doesnt work... even only the autocomplete part doesnt work, and this is the only id with this name on the hole document
Shady
Is it just the autocomplete that doesn't work or both?
Pekka
both, but I was trying your autocomplete, without the setAttribute...
Shady
@Shady strange. No Javascript errors in the console?
Pekka
no, none........
Shady