HTML Input VS HTML Button

  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

what is the diff. btw. input vs button in ie. As an example.. i tried to submit an action in the same file from an input and from a button. So if i say when i press the input with the name add, the action for submiting the name add will trigger an event and so on, but when i press a button with the same name it triggers all events in the page in ie. how could i fix such a thing!?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

A <button> can have child elements, such as <img> elements for icons. An <input> element can't.

Code: [ Select ]
<button ...>
<img .../>&nbsp;<span>Button Label</span>
</button>
  1. <button ...>
  2. <img .../>&nbsp;<span>Button Label</span>
  3. </button>
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

i know this.. but if i call an input with the name="add" to do if($_POST['add']) do an action.. an input goes to the designated place unlike the button that goes thtough all the events of the script and all at oance.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Are you using a submit button or a button button ?

Code: [ Select ]
<button type="submit"/>
<button type="button"/>
  1. <button type="submit"/>
  2. <button type="button"/>
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

a submit button.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Are you giving the button a "value" attribute ?

Code: [ Select ]
<button type="submit name="button" value="button">Button</button>


Or, have you tried isset instead of just if ?

Code: [ Select ]
if (isset($_POST['button']))
{
   //stuff
}
  1. if (isset($_POST['button']))
  2. {
  3.    //stuff
  4. }
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

ok.. i tryed this:
Code: [ Select ]
<?
if (isset($_POST['button']))
{
echo 'but1';
}
elseif (isset($_POST['button2']))
{
echo 'but2';
}
else{}
?>
<form method="post">
<button type="submit" name="button" value="button">Button</button>
<button type="submit" name="button2" value="button2">Button2</button>
<button type="submit" name="clar" value="clar">Clear</button>
</form>
  1. <?
  2. if (isset($_POST['button']))
  3. {
  4. echo 'but1';
  5. }
  6. elseif (isset($_POST['button2']))
  7. {
  8. echo 'but2';
  9. }
  10. else{}
  11. ?>
  12. <form method="post">
  13. <button type="submit" name="button" value="button">Button</button>
  14. <button type="submit" name="button2" value="button2">Button2</button>
  15. <button type="submit" name="clar" value="clar">Clear</button>
  16. </form>


in ff works ok.. but in ie when i press the second button it still goes to the first action instead of the second that is supposed to, same goes for the clear button.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

This seems to do the trick in Opera, which shares some behavior with IE. I don't have access to IE to test it there though.

Code: [ Select ]
<?
$yes = 'no';
if (!empty($_POST['button']))
{
    switch ($_POST['button'])
    {
        case 'button1':
            $yes = 'yes 1';
        break;
        case 'button2':
            $yes = 'yes 2';
        break;
        case 'button3':
            $yes = 'yes 3';
        break;
        default:
            $yes = 'yes default';
        break;
    }
}
else if (!empty($_POST['submit']))
{
    $yes = 'submit';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Title</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <link rel='stylesheet' type='text/css' href='style.css' />
</head>
<body>
    <div>
    <form action="test.php" method="post">
    <div>
    <input type="submit" name="submit" value="submit"/>
    <button type="submit" name="button" value="button1">Button 1</button>
    <button type="submit" name="button" value="button2">Button 2</button>
    <button type="submit" name="button" value="button3">Button 3</button>
    </div>
    </form>
    <?php echo $yes; ?>
    </div>
</body>
</html>
  1. <?
  2. $yes = 'no';
  3. if (!empty($_POST['button']))
  4. {
  5.     switch ($_POST['button'])
  6.     {
  7.         case 'button1':
  8.             $yes = 'yes 1';
  9.         break;
  10.         case 'button2':
  11.             $yes = 'yes 2';
  12.         break;
  13.         case 'button3':
  14.             $yes = 'yes 3';
  15.         break;
  16.         default:
  17.             $yes = 'yes default';
  18.         break;
  19.     }
  20. }
  21. else if (!empty($_POST['submit']))
  22. {
  23.     $yes = 'submit';
  24. }
  25. ?>
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  27. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  28. <head>
  29.     <title>Title</title>
  30.     <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  31.     <meta http-equiv="Content-Style-Type" content="text/css" />
  32.     <link rel='stylesheet' type='text/css' href='style.css' />
  33. </head>
  34. <body>
  35.     <div>
  36.     <form action="test.php" method="post">
  37.     <div>
  38.     <input type="submit" name="submit" value="submit"/>
  39.     <button type="submit" name="button" value="button1">Button 1</button>
  40.     <button type="submit" name="button" value="button2">Button 2</button>
  41.     <button type="submit" name="button" value="button3">Button 3</button>
  42.     </div>
  43.     </form>
  44.     <?php echo $yes; ?>
  45.     </div>
  46. </body>
  47. </html>
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

exactly the same thing the only difference is that now it just chooses the default value no matter what button i press.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

It's not looking good.

http://www.dev-archive.net/articles/for ... ttons.html
http://allinthehead.com/retro/330/copin ... of-buttons
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

i think i'll just work with inputs and go arround the buttons. IE realy sucks!
  • dyfrin
  • Expert
  • Expert
  • User avatar
  • Posts: 503
  • Loc: WI

Post 3+ Months Ago

I have seen some work arounds for the "file upload" button replacing where javascript will put a div on top of the input that has an image, you can try something like that to get your nice looking button.

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 51 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.