I'm adding a Greasemonkey script to spice up a page where I work at, but I'm running into problem. I'm looking to add default values into form fields so every time I fill out the form I don't have to add the same values.
When looking at the id
and name
attributes on the form they are surrounded with brackets!
For example:
<input id="[[FormGen]]Contact" type="text"
value="" name="[[FormGen]]Contact">
</input>
Now, I do not have access to any server side code, and I'm viewing this from the source code. One thing to note is that this form works perfectly fine. I'm curious as to what these brackets could possibly do or mean, but that's not my root problem.
The root problem is that when I go to obtain the value with jQuery it does not recognize the id that I use. In other words, this is not working:
("#[[FormGen]]Contact").val("test");
One more note - the form has about 20 total fields. All ID and Name attribute values begin with [[FormGen]]
.
You can escape them:
$('#\\[\\[FormGen\\]\\]Contact')
Or use something like this:
$(document.getElementById('[[FormGen]]Contact'))