In <41***********************@news.xs4all.nl> Erwin Moller <si******************************************@spam yourself.com> writes:
J Krugman wrote:
I have a form with a couple of submit buttons, plus a "pseudolink"
that is also supposed to submit the form; the submitted form data
feeds to a CGI script. The two submit buttons have the name
"go_for_it", so that when the form is submitted, the CGI script
looks for the value of the CGI parameter "go_for_it". I want the
pseudolink to set the value of this CGI parameter prior to submitting
the form, but I can't get it to work. Here's the latest version
of the HTML+JavaScript code for the pseudolink:
<a onclick="var f = document.forms['myform'];
f['go_for_it'][0].value='foo'; f.submit(); return false;"
href="warn_no_js.html">pseudolink</a>
After one clicks on the pseudolink, the receiving CGI reports that
the CGI parameter "go_for_it" is not defined. What am I doing
wrong?
Hi Jill,
Did you create a formvariable (possibly hidden) that goes by the name
go_for_it ??
I'm not sure what you mean by a form variable. There are two submit
buttons each of which has "go_for_it" as its name attribute, but
they have different value attributes (say "foo" and "bar"). When
the form is submitted by clicking on one of these submit buttons,
the CGI at the server end receives the value attribute of the
clicked submit button as the value of the CGI parameter "go_for_it".
What I want to do is to be able to set that same CGI parameter and
submit the form when the user clicks on the pseudolink mentioned
above.
And why do you use f['go_for_it'][0].value='foo' instead of
f['go_for_it'].value='foo' ???
Because when I inserted the statement
alert(f['go_for_it'])
I learned that f['go_for_it'] is not an input element but rather
a NodeList object; if I replace this alert statement with
for (var i = 0; i < f['go_for_it'].length; ++i) {
alert(f['go_for_it'][i]);
alert(f['go_for_it'][i].name);
alert(f['go_for_it'][i].value);
}
I get the following results:
object HTMLInputElement
go_for_it
foo
object HTMLInputElement
go_for_it
bar
I now realize that setting f['go_for_it'][0].value can't be the
way to set the value of the CGI parameter, because that value is
already set even before one clicks on the submit button...
Bottom line: what I need to find out is what field of the form or the
appropriate input element I must set to the desired value so that the
receiving CGI script can read it as the value of the "go_for_it" CGI
parameter.
TIA
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.