I search for an answer and while I found discusions on the issue I did not see any solutions.
What I want to do is fill in a HTML form field from javascript. I can do this with hand written html, but can not fiind the correct way to refere to fields by name when they follow the pattern used by the form functions (edit[name] or edit[name][]).
I want to have the onclick handler to a button call a function with a reference to the field, something like function(this.form.field_name); My attempts so far though to match field_name with the name generated by the Drupal form functions have produced javascript errors.
Does any one have a solution for this?
Thanks
Steve
Comments
Have the same question
Did you ever solve this?
Thanks
I came across a way of making it work
By looking at some other javascript based modules I was able to figure out that you can do something like:
you can get a pointer to the form element that has the name edit[name].
Thanks
I will need to try that out and see if it does the trick.
getElementById
You can use document.getElementById('edit-name') where name is the form item name. Id's generated by drupal form functions take this form: edit-name
MAYC