Your problem is very similar to this:
Just differs on what to do with the dropdown values at the end. Note how little scripting is actually needed. Certainly not needed to run the named query (and probably shouldn't be, to keep the flow of data smoothly asynchronous).