javascript - AppleScript - If document.getElementById value is null, enter value -


first time asking question, let me know if i'm doing wrong. have applescript takes values numbers document, , enters them various fields of webform using document.getelementbyid.

it works flawlessly, want add feature only fill in value if field in webform blank.

my idea code going this:

if ("document.getelementbyid('something').value = null)             execute javascript ("document.getelementbyid('something').value = '" & valuetofillin & "'") else     move on 

can advise me on best way check if document.getelementbyid value null, , how proceed? appreciated!

heres simple alternative well. modify needs. believe explained , obvious of going on in script. else statement not required "move on". once if statement checked, script moves on without needing else unless want execute else if field has value.

-- tested here -> http://meyerweb.com/eric/tools/dencoder/  set fieldvalue getinputbyid("dencoder") of me  if fieldvalue ""     inputbyid("dencoder", "im allowed input text because empty") of me else     "the field not empty" end if   -- simple handlers -- retrieve value of elementbyid getinputbyid(theid)     tell application "safari"     set output javascript "document.getelementbyid('" & theid & "').value;" in document 1 end tell return output end getinputbyid  -- input string element id inputbyid(theid, thevalue)     tell application "safari"     javascript "  document.getelementbyid('" & theid & "').value ='" & thevalue & "';" in document 1 end tell end inputbyid 

Comments