Applescript and Safari - automating drop-down menu selection

Hi there.
I’m working on an Applescript that will automatically select a certain value from a drop-down menu.
Here’s the webpage’s relevant HTML:

1 2 4

I want to have the Applescript automatically select the value of ‘2’. Here’s what I’ve got that’s currently not working:

tell application "Safari"
	-- go to appropriate URL to login
	open location "http://www.xxx.com"
	delay 4
	do JavaScript "document.forms['select']['DropDownListSeats'].option.value = '2'"
end tell

Any help is appreciated!

Hi.

I can’t help with the JavaScript code, I’m afraid, but Safari’s do JavaScript command has a required in parameter that specifies the document to which the JavaScript’s applied, eg.:

tell application "Safari"
	-- Blah blah.
	
	do JavaScript "document.forms['select']['DropDownListSeats'].option.value = '2'" in front document
end tell