Getting FORM DATA from a web page and setting it to a variable

I need a solution to get data from a web page form.

Here is the line of html code that displays the text field in question:

I NEED THE DATA IN HERE!

I have a variable in my applescript called JOBDescription.

I would like to set this variable to the contents of the text field in the above html code.

What is the proper Java code?

something like:
tell application “safari”
do JavaScript “set JOBDescription to contents of text field “txtDescription”” in document 1
end tell

Any info would be greatly appreciated,
AppleScriptJunkie

I’m sure you already know this one :wink:

set js to "document.forms[0].elements[0].value"
tell app "Safari" to set JOBDescription to (do javascript js in document 1)

Where “0” would mean “the first element in the first form”, so you can adjust it to match your needs, depending on the HTML source.
If you have the name, you can also use it:

set js to "document.forms[0].txtDescription.value"
--> or
set js to "document.forms[0].elements['txtDescription'].value"

You could even substitute “forms[0]” with the form name, if any. Eg:

set js to "document.FORMNAME.txtDescription.value