clicking a web button without simulating a mouse click

Is there a way to click a button (image button) in a webpage (using safari) by its name or something? because I programed a script but it needs to simulate a mouse click to click the button and it needs to be in the exact coordinates.
the other question is: is there a way to select a text field (in a web page) by its name to then write something on it?

Anything can be done in a web page using safari, applescript and javascript. If you post the related HTML code (or point to a URL), it will be faster to explain.