Тег <button></button>



Этот тег определяет кнопку.



Аргумент Значение
autofocus autofocus
disabled disabled
form id form
formaction URL
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
formmethod GET
POST
formnovalidate formnovalidate
name name button
value value for form
type button
reset
submit




index.php
  • <?php
  • class Electro {
  •  private $show0;
  •  private $show1;
  •  private $price;
  •  function __construct($arg0, $arg1, $arg2) {
  •   $this->show0 = $arg0;
  •   $this->show1 = $arg1;
  •   $this->price = $arg2;
  •  }
  •  function Res() {
  •   return $this->show1 - $this->show0;
  •  }
  •  function Sum() {
  •   return round( $this->price * $this->Res(), 2);
  •  }
  • }
  • ?>
  •  
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>Name Page</title>
  • </head>
  • <body>
  •  <?php
  •  if($_SERVER['REQUEST_METHOD'] == 'POST') {
  •   $show0 = abs((int)$_POST['show0']);
  •   $show1 = abs((int)$_POST['show1']);
  •   $price = (float)$_POST['price'];
  •   $E = new Electro($show0, $show1, $price);
  •  }
  •  ?>
  •  <form id="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  •   <fieldset>
  •    <legend>To calculate electricity</legend>
  •    <br />
  •    <input type="text" name="show0" value="<?php echo $show0; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The start data enter</label>
  •    <br />
  •    <br />
  •    <input type="text" name="show1" value="<?php echo $show1; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The end data enter</label>
  •    <br />
  •    <br />
  •    <input type="text" name="price" value="<?php echo $price; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The price 1 kW/hour of electricity</label>
  •    <br />
  •    <br />
  •    <button type="submit" value="res">Calculate</button>
  •    <br />
  •    <br />
  •   </fieldset>
  •   <br />
  •   <fieldset>
  •    <legend>The sum of electricity</legend>
  •    <br />
  •    <?php
  •    if($_SERVER['REQUEST_METHOD']=='POST') {
  •     echo 'Sum = ', $E->Sum();
  •    }
  •    ?>
  •    <br />
  •    <br />
  •   </fieldset>
  •  </form>
  • </body>
  • </html>
  • <?php
  • class Electro {
  •  private $show0;
  •  private $show1;
  •  private $price;
  •  function __construct($arg0, $arg1, $arg2) {
  •   $this->show0 = $arg0;
  •   $this->show1 = $arg1;
  •   $this->price = $arg2;
  •  }
  •  function Res() {
  •   return $this->show1 - $this->show0;
  •  }
  •  function Sum() {
  •   return round( $this->price * $this->Res(), 2);
  •  }
  • }
  • ?>
  •  
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>Name Page</title>
  • </head>
  • <body>
  •  <?php
  •  if($_SERVER['REQUEST_METHOD'] == 'POST') {
  •   $show0 = abs((int)$_POST['show0']);
  •   $show1 = abs((int)$_POST['show1']);
  •   $price = (float)$_POST['price'];
  •   $E = new Electro($show0, $show1, $price);
  •  }
  •  ?>
  •  <form id="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  •   <fieldset>
  •    <legend>To calculate electricity</legend>
  •    <br />
  •    <input type="text" name="show0" value="<?php echo $show0; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The start data enter</label>
  •    <br />
  •    <br />
  •    <input type="text" name="show1" value="<?php echo $show1; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The end data enter</label>
  •    <br />
  •    <br />
  •    <input type="text" name="price" value="<?php echo $price; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The price 1 kW/hour of electricity</label>
  •    <br />
  •    <br />
  •    <button type="submit" value="res">Calculate</button>
  •    <br />
  •    <br />
  •   </fieldset>
  •   <br />
  •   <fieldset>
  •    <legend>The sum of electricity</legend>
  •    <br />
  •    <?php
  •    if($_SERVER['REQUEST_METHOD']=='POST') {
  •     echo 'Sum = ', $E->Sum();
  •    }
  •    ?>
  •    <br />
  •    <br />
  •   </fieldset>
  •  </form>
  • </body>
  • </html>