Scripting Javascript Form-Submits in Safari

I know this subject is covered here extensively, but I’m at a loss as to why my script isn’t working. I am trying to javascript the following commands in Safari:

  1. login to a website
  2. change a pulldown menu value
  3. logout

I have all of it working fine except the part where the value of the pulldown menu is changed. Instead of changing to the value I want, it turns blank, before the submit command is executed, and when I check, I find that the proper value has not been submitted.

For reference, from the website HTML:

First:

<form id="flogout" name="flogout" method="POST"> <input type="hidden" name="logout" value="1"> <input type="hidden" name="pg" value="">
And then:

[code]

Online Leave Me A Meassage Away Offline [/code] So this is the part of my script where I would like it to set the pulldown to "Away"
set pflogout to "document.forms[\"flogout\"].elements[\"useravailability\"].selectedIndex=\"817220\"
    document.forms[\"flogout\"].submit()"

tell application "Safari"
    do JavaScript pflogout in document 1
end tell

Like I said, everything else works fine but the pulldown goes blank before the form is submitted and the proper value is not submitted.

Any clues here?

looking for a way to do something similar myself. Can’t seem to figure out how to access the popup field.