multiple image submit button problems

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

    multiple image submit button problems

    I currently have two image submit buttons. The code generated looks like
    so:

    <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
    title="Add" name="btn_cart" value="buy">
    <input type="image" src="modify.gif " border="0" alt="modify"
    title="modify" name="btn_modif y" value="modify">

    In mozilla everything works great, but in Konqueror and MSIE the if
    statement I'm using to detect which button was press does not work.

    if (isset($HTTP_PO ST_VARS['btn_cart'])){ do stuff }

    Does anyone know how to fix this without resorting to javascript?


    thanx
    -ryan
  • Alvaro G Vicario

    #2
    Re: multiple image submit button problems

    *** Ryan wrote/escribió (Fri, 23 Jan 2004 04:41:53 -0800):[color=blue]
    > In mozilla everything works great, but in Konqueror and MSIE the if
    > statement I'm using to detect which button was press does not work.[/color]

    This could be a good start:

    <pre><?
    print_r($_POST) ;
    ?>/pre>



    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --

    Comment

    • Sales at 3A Web Hosting

      #3
      Re: multiple image submit button problems

      Hi Ryan
      [color=blue]
      > <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
      > title="Add" name="btn_cart" value="buy">
      > <input type="image" src="modify.gif " border="0" alt="modify"
      > title="modify" name="btn_modif y" value="modify">
      >
      > In mozilla everything works great, but in Konqueror and MSIE the if
      > statement I'm using to detect which button was press does not work.
      >
      > if (isset($HTTP_PO ST_VARS['btn_cart'])){ do stuff }
      >
      > Does anyone know how to fix this without resorting to javascript?[/color]

      Where are you checking 'btn_modify'? The line above only checks
      'btn_cart'

      My preferred method would be:-

      <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
      title="Add" name="action" value="buy">
      <input type="image" src="modify.gif " border="0" alt="modify"
      title="modify" name="action" value="modify">


      if ($action == "buy") {

      // do buy bit here

      }
      elseif ($action == "modify") {

      // do modify bit here

      }
      --
      Colin

      3A Web Hosting Team

      Comment

      • Chung Leong

        #4
        Re: multiple image submit button problems

        Wouldn't it make more sense to use the same name for both buttons?

        <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
        title="Add" name="btn_actio n" value="buy">
        <input type="image" src="modify.gif " border="0" alt="modify"
        title="modify" name="btn_actio n" value="modify">

        if($_POST['btn_action'] == 'buy') ...

        else if($_POST['btn_action'] == 'modify') ...

        Uzytkownik "Ryan" <rcdetert@nospa mmerz.ucdavis.e du> napisal w wiadomosci
        news:pan.2004.0 1.23.12.41.50.8 90560@nospammer z.ucdavis.edu.. .[color=blue]
        > I currently have two image submit buttons. The code generated looks like
        > so:
        >
        > <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
        > title="Add" name="btn_cart" value="buy">
        > <input type="image" src="modify.gif " border="0" alt="modify"
        > title="modify" name="btn_modif y" value="modify">
        >
        > In mozilla everything works great, but in Konqueror and MSIE the if
        > statement I'm using to detect which button was press does not work.
        >
        > if (isset($HTTP_PO ST_VARS['btn_cart'])){ do stuff }
        >
        > Does anyone know how to fix this without resorting to javascript?
        >
        >
        > thanx
        > -ryan[/color]


        Comment

        • Ryan

          #5
          Re: multiple image submit button problems

          On Fri, 23 Jan 2004 16:26:29 +0000, Sales at 3A Web Hosting wrote:
          [color=blue]
          > Hi Ryan
          >[color=green]
          >> <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
          >> title="Add" name="btn_cart" value="buy">
          >> <input type="image" src="modify.gif " border="0" alt="modify"
          >> title="modify" name="btn_modif y" value="modify">
          >>
          >> In mozilla everything works great, but in Konqueror and MSIE the if
          >> statement I'm using to detect which button was press does not work.
          >>
          >> if (isset($HTTP_PO ST_VARS['btn_cart'])){ do stuff }
          >>
          >> Does anyone know how to fix this without resorting to javascript?[/color]
          >
          > Where are you checking 'btn_modify'? The line above only checks
          > 'btn_cart'
          >
          > My preferred method would be:-
          >
          > <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
          > title="Add" name="action" value="buy">
          > <input type="image" src="modify.gif " border="0" alt="modify"
          > title="modify" name="action" value="modify">
          >
          >
          > if ($action == "buy") {
          >
          > // do buy bit here
          >
          > }
          > elseif ($action == "modify") {
          >
          > // do modify bit here
          >
          > }[/color]


          Tried that, works fine in Mozilla but in Konqueror and Explorer it still
          does not work.
          Perhaps there is some bad html elsewhere that is messing things up. I'll
          look for those errors when I get a chance.


          -ryan

          Comment

          • Rahul Anand

            #6
            Re: multiple image submit button problems

            Sometimes the posted data does not have the value content of submit
            button.
            For example if the focus is in Inputbox and you press "enter" key. In
            this case the first submit button will have focus.

            So whatever you write in name, you need check the second submit button
            in your if condition.

            eg:

            if(!empty($_POS T))
            {
            // Form Posted

            if(isset($_POST['second_button_ name']))
            /*
            You can code this way if name is same for both button
            if(isset($_POST['button_name'])
            && $_POST['button_name'] == "second_button_ value")
            */
            {
            // Second button clicked

            }
            else
            {
            // First button clicked

            }
            }

            --
            Cheers,
            Rahul Anand


            "Ryan" <rcdetert@nospa mmerz.ucdavis.e du> wrote in message news:<pan.2004. 01.23.12.41.50. 890560@nospamme rz.ucdavis.edu> ...[color=blue]
            > I currently have two image submit buttons. The code generated looks like
            > so:
            >
            > <input type="image" src="button_in_ cart.gif" border="0" alt="Add"
            > title="Add" name="btn_cart" value="buy">
            > <input type="image" src="modify.gif " border="0" alt="modify"
            > title="modify" name="btn_modif y" value="modify">
            >
            > In mozilla everything works great, but in Konqueror and MSIE the if
            > statement I'm using to detect which button was press does not work.
            >
            > if (isset($HTTP_PO ST_VARS['btn_cart'])){ do stuff }
            >
            > Does anyone know how to fix this without resorting to javascript?
            >
            >
            > thanx
            > -ryan[/color]

            Comment

            • 3A Web Hosting

              #7
              Re: multiple image submit button problems

              Hi Ryan
              [color=blue]
              > Tried that, works fine in Mozilla but in Konqueror and Explorer it still
              > does not work.
              > Perhaps there is some bad html elsewhere that is messing things up. I'll
              > look for those errors when I get a chance.[/color]

              Strange, it works fine here using Nutscrape, IE, Opera & kmeleon.
              Have you tried an 'echo $action;' before the 'if' to make sur you are
              picking up the variable?

              Maybe add

              if (!$action) {echo "NO VARIABLE PASSED";}

              elseif ($action etc....

              --
              Colin

              3A Web Hosting Team

              Comment

              • Ryan

                #8
                Re: multiple image submit button problems

                On Sat, 24 Jan 2004 13:59:42 +0000, 3A Web Hosting wrote:
                [color=blue]
                > Hi Ryan
                >[color=green]
                >> Tried that, works fine in Mozilla but in Konqueror and Explorer it still
                >> does not work.
                >> Perhaps there is some bad html elsewhere that is messing things up. I'll
                >> look for those errors when I get a chance.[/color]
                >
                > Strange, it works fine here using Nutscrape, IE, Opera & kmeleon.
                > Have you tried an 'echo $action;' before the 'if' to make sur you are
                > picking up the variable?
                >
                > Maybe add
                >
                > if (!$action) {echo "NO VARIABLE PASSED";}
                >
                > elseif ($action etc....[/color]


                I don't get it, the image button isn't getting passed into the form post
                data. It isn't set, it isn't showing up at all, only works in mozilla.
                Anyone offlist want to have a go at the html I'm generating?

                -ryan

                Comment

                • 3A Web Hosting

                  #9
                  Re: multiple image submit button problems

                  Hi Ryan
                  [color=blue]
                  >
                  > I don't get it, the image button isn't getting passed into the form post
                  > data. It isn't set, it isn't showing up at all, only works in mozilla.
                  > Anyone offlist want to have a go at the html I'm generating?[/color]

                  Email me a copy of your script and I'll have a look at it for you.

                  --
                  Colin

                  3A Web Hosting Team

                  Comment

                  • twinclones
                    New Member
                    • Jun 2006
                    • 1

                    #10
                    The submit button works, but in IE, the value attribute is ignored

                    Comment

                    Working...