Can you have multiple <BUTTON> in a form? 
Author Message
 Can you have multiple <BUTTON> in a form?

Here's the php code below. It's from a larger application. The
question is simply this: why is it when I select EITHER the edit or
delete button, BOTH values get displayed by the echo? Why both and not
just the one I selected?

Help!

Joe

<?php

$EDIT   = $HTTP_POST_VARS["Edit"];
$DELETE = $HTTP_POST_VARS["Delete"];

echo("E=$EDIT D=$DELETE");

?>

<HTML>
  <BODY BGCOLOR=#FFF5EE>
    <CENTER>
      <FORM ACTION="xxx.php" METHOD=POST>
<?php
        $PN=1;
        echo("<BUTTON TYPE=submit NAME=Edit STYLE='color:
red'>Edit-$PN  </BUTTON>");
        echo("<BUTTON TYPE=submit NAME=Delete>Delete-$PN</BUTTON>");
?>
      </FORM>
  </BODY>
</HTML>



Tue, 21 Jun 2005 02:30:13 GMT  
 Can you have multiple <BUTTON> in a form?

Quote:
> Here's the php code below. It's from a larger application. The
> question is simply this: why is it when I select EITHER the edit or
> delete button, BOTH values get displayed by the echo? Why both and not
> just the one I selected?

> Help!

> Joe

> <?php

> $EDIT   = $HTTP_POST_VARS["Edit"];
> $DELETE = $HTTP_POST_VARS["Delete"];

> echo("E=$EDIT D=$DELETE");

> ?>

> <HTML>
>   <BODY BGCOLOR=#FFF5EE>
>     <CENTER>
>       <FORM ACTION="xxx.php" METHOD=POST>
> <?php
>         $PN=1;
>         echo("<BUTTON TYPE=submit NAME=Edit STYLE='color:
> red'>Edit-$PN  </BUTTON>");
>         echo("<BUTTON TYPE=submit NAME=Delete>Delete-$PN</BUTTON>");
> ?>
>       </FORM>
>   </BODY>
> </HTML>

Try this:
<input type="submit" name="action" value="One"/>
<input type="submit" name="action" value="Two"/>

Now all you have to do, is to read the value of action in your php code. If
the value is "One" then the first button was pressed, etc. Of course you can
use other name than "action" for the buttons.



Tue, 21 Jun 2005 05:54:33 GMT  
 Can you have multiple <BUTTON> in a form?

Quote:

> Here's the php code below. It's from a larger application. The
> question is simply this: why is it when I select EITHER the edit or
> delete button, BOTH values get displayed by the echo? Why both and
> not just the one I selected?

I cant replicate your exakt problem, but I did notice that you are
missing 'value' attributes in your buttons, which is not good. It may
even be that different browsers sends different things in this
case. In my case, the browser sends the value "" (empty) for the
pressed button. Use isset() to test for that.

if (isset($_POST["Edit"])) echo "\nedit is set\n";
if (isset($_POST["Delete"])) echo "\ndelete is set\n";

But, try to add a value to you buttons.

Learn some html while you are at it. For instance, attributes should
be like this: attr="my value". Single or no quotes are not reliable.

Quote:
> echo("<BUTTON TYPE=submit NAME=Edit STYLE='color: red'>Edit-$PN  </BUTTON>");
> echo("<BUTTON TYPE=submit NAME=Delete>Delete-$PN</BUTTON>");



Tue, 21 Jun 2005 06:08:04 GMT  
 Can you have multiple <BUTTON> in a form?

Quote:

> Here's the php code below. It's from a larger application. The
> question is simply this: why is it when I select EITHER the edit or
> delete button, BOTH values get displayed by the echo? Why both and not
> just the one I selected?

> Help!

> Joe

> <?php

> $EDIT   = $HTTP_POST_VARS["Edit"];
> $DELETE = $HTTP_POST_VARS["Delete"];

> echo("E=$EDIT D=$DELETE");

> ?>

> <HTML>
>   <BODY BGCOLOR=#FFF5EE>
>     <CENTER>
>       <FORM ACTION="xxx.php" METHOD=POST>
> <?php
>         $PN=1;
>         echo("<BUTTON TYPE=submit NAME=Edit STYLE='color:
> red'>Edit-$PN  </BUTTON>");
>         echo("<BUTTON TYPE=submit NAME=Delete>Delete-$PN</BUTTON>");
> ?>
>       </FORM>
>   </BODY>
> </HTML>

My guess is that a <BUTTON> tag is like text elements where it always
gets sent whether you click it or not.  Try using the normal submit buttons.
<input type="submit" name="edit" value="Edit" style="color: red">
<input type="submit" name="delete" value="Delete">


Mon, 20 Jun 2005 23:17:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

2. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

3. <><><> FLOODFILL <><><>

4. >>>HELP, DECOMPILER<<<

5. <<<XXX Password>>>

6. <<<XXX Password>>>

7. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

8. <<<XXX Password>>>

9. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

10. >>>>>>>>>>>>>>>>>>>HEY!<<<<<<<<<<<<<<<<<<<<<<<

11. ------>>>>> REVERSING A STRING <<<<<-----

 

 
Powered by phpBB® Forum Software