Setting CGI parameter programmatically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J Krugman

    Setting CGI parameter programmatically





    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_j s.html">pseudol ink</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?

    Thanks!

    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.

  • Erwin Moller

    #2
    Re: Setting CGI parameter programmaticall y

    J Krugman wrote:
    [color=blue]
    >
    >
    >
    >
    > 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_j s.html">pseudol ink</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?
    >
    > Thanks!
    >
    > jill
    >[/color]

    Hi Jill,

    Did you create a formvariable (possibly hidden) that goes by the name
    go_for_it ??

    And why do you use f['go_for_it'][0].value='foo' instead of
    f['go_for_it'].value='foo' ???

    Regards,
    Erwin Moller

    Comment

    • J Krugman

      #3
      Re: Setting CGI parameter programmaticall y


      In <4108b5eb$0$933 24$e4fe514c@new s.xs4all.nl> Erwin Moller <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> writes:
      [color=blue]
      >J Krugman wrote:[/color]
      [color=blue][color=green]
      >> 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_j s.html">pseudol ink</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?[/color][/color]
      [color=blue]
      >Hi Jill,[/color]
      [color=blue]
      >Did you create a formvariable (possibly hidden) that goes by the name
      >go_for_it ??[/color]

      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.
      [color=blue]
      >And why do you use f['go_for_it'][0].value='foo' instead of
      >f['go_for_it'].value='foo' ???[/color]

      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 HTMLInputElemen t
      go_for_it
      foo
      object HTMLInputElemen t
      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.

      Comment

      Working...