On Nov 15, 10:17 am, Steve Swift <Steve.J.Sw...@gmail.com> wrote:
> I don't have a particular webpage to point you to; I thought about this
> whilst walking my dog this morning and don't have an example page. That
> said, this question doesn't really require a "working" example.
>
> I have a form with two <SELECT> controls. Both contain:
> onChange="this.form.submit()"
>
> So whichever one changes, my POST data contains both elements. How can I
> know which one changed?
>
> My idea is to include this in the form:
> <INPUT TYPE=HIDDEN NAME=CONTROL VALUE="">
>
> Then to change each onChange to something like this:
> onChange="this.form.CONTROL.value='CONTROL_A';this .form.submit()"
> where I'd use the name of the control in place of CONTROL_A of course.
>
> So now I'll have an additional "CONTROL" value in my POST data telling
> me which control changed.
>
> Is this a workable solution? Is there a better way of doing things?
Hi Steve!
There is a better way. You could just set a variable and change the
"action" string for your form.
In the header of your document, put something like:
<script language="text/javascript"><!--
var changedSelect = '';
var programToCall = "/someProgram.exe";
function SetActionString() {
actionString = programToCall + "?" + changedSelect;
return actionString;
}
</script>
In the body of your document, put something like:
<form id="aForm">
<select id="first"
onChange="document.changedSelect=this.id;document. forms['aForm'].action=SetActionString();">
<select id="second"
onChange="document.changedSelect=this.id;document. forms['aForm'].action=SetActionString();">
Not tested and improving code still possible, but the idea is above.
The name of the changed select box will be passed to in the
QUERY_STRING environment variable that you can read server side, this
even if your form is submitted via "POST".
I use similar technique to pass the language in forms that are sent in
POST mode.
Have a look at
http://www.altipoint.com/cgiContouri...touring.en.htm
to see.
This is a webservice available in 4 languages. Using the query string
let me know from step to step in which language to display the text.
Julien