$_POST behavior from input=submit vs input-type=button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Victor A. Cuya

    $_POST behavior from input=submit vs input-type=button

    Hello all,

    I have been trying to solve an annoying behavior with PHP (I think).
    Maybe some of you have encountered the same and have some ideas.

    I have an html form and I use an <input type="button"> element with
    the onClick event that calls a javascript funtion. Once the script's
    content has been processed, I execute the form.submit() directive.

    I would like to combine the html form and the PHP script into one, and
    use action="<?php echo($PHP_SELF) ?>".

    When the html form has <input type="button" name="theButton "
    value="thisisth etrigger" onclick="doThis (this.form)">bu t PHP cannot
    'read' the value of $_POST["theButton"] after form.submit().

    If I substitute the <input type="button"> for <input type="submit">
    then PHP reads the value just fine. Some may argue to just use the
    latter option, but that will cost me a trip back to the server to
    basically do a lot of validation that can be very easily accomplished
    on the client side.

    Any suggestions will be greatly appreciated.

  • S Austin

    #2
    Re: $_POST behavior from input=submit vs input-type=button

    use the input type=submit, move the button event to the form i.e., <form
    onsubmit="doThi s(this)"

    Victor A. Cuya wrote:[color=blue]
    > Hello all,
    >
    > I have been trying to solve an annoying behavior with PHP (I think).
    > Maybe some of you have encountered the same and have some ideas.
    >
    > I have an html form and I use an <input type="button"> element with
    > the onClick event that calls a javascript funtion. Once the script's
    > content has been processed, I execute the form.submit() directive.
    >
    > I would like to combine the html form and the PHP script into one, and
    > use action="<?php echo($PHP_SELF) ?>".
    >
    > When the html form has <input type="button" name="theButton "
    > value="thisisth etrigger" onclick="doThis (this.form)">bu t PHP cannot
    > 'read' the value of $_POST["theButton"] after form.submit().
    >
    > If I substitute the <input type="button"> for <input type="submit">
    > then PHP reads the value just fine. Some may argue to just use the
    > latter option, but that will cost me a trip back to the server to
    > basically do a lot of validation that can be very easily accomplished
    > on the client side.
    >
    > Any suggestions will be greatly appreciated.
    >[/color]

    Comment

    • sma1king

      #3
      Re: $_POST behavior from input=submit vs input-type=button

      "Victor A. Cuya" <vcuya@mindspri ng.com> wrote in message
      news:5mm1a01pbj ccljape5j0j4qsp 3bea64pl4@4ax.c om...[color=blue]
      > Hello all,
      >
      > I have been trying to solve an annoying behavior with PHP (I think).
      > Maybe some of you have encountered the same and have some ideas.
      >
      > I have an html form and I use an <input type="button"> element with
      > the onClick event that calls a javascript funtion. Once the script's
      > content has been processed, I execute the form.submit() directive.
      >
      > I would like to combine the html form and the PHP script into one, and
      > use action="<?php echo($PHP_SELF) ?>".
      >
      > When the html form has <input type="button" name="theButton "
      > value="thisisth etrigger" onclick="doThis (this.form)">bu t PHP cannot
      > 'read' the value of $_POST["theButton"] after form.submit().
      >
      > If I substitute the <input type="button"> for <input type="submit">
      > then PHP reads the value just fine. Some may argue to just use the
      > latter option, but that will cost me a trip back to the server to
      > basically do a lot of validation that can be very easily accomplished
      > on the client side.
      >
      > Any suggestions will be greatly appreciated.[/color]

      Dear Victor,

      I think you may be stuck. Take a look at Alan Flavell's comments on this
      issue in http://ppewww.ph.gla.ac.uk/~flavell/www/trysub.html

      George


      Comment

      Working...