Тег <fieldset></fieldset>




Этот тег группирует элементы в форме.



Аргумент Значение
disabled disabled
form form_id
name text




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);
  •   if($_REQUEST['clear']) {
  •    $show0 = null;
  •    $show1 = null;
  •    $price = null;
  •   }
  •  }
  •  ?>
  •  <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</label>
  •    <br />
  •    <br />
  •    <input type="text" name="show1" value="<?php echo $show1; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The end data</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 />
  •    <input type="submit" name="res" value="Calculate" />
  •    <br />
  •    <br />
  •    <input type="submit" name="clear" value="&nbsp;&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;&nbsp;" />
  •    <br />
  •    <br />
  •   </fieldset>
  •   <br />
  •   <fieldset>
  •    <legend>The sum of electricity</legend>
  •    <br />
  •    <?php
  •    if($_SERVER['REQUEST_METHOD']=='POST' && $_REQUEST['res'] && !$_REQUEST['clear']) {
  •     echo 'Sum = ', '<b>', $E->Sum(), '</b>';
  •    }
  •    else {
  •     echo null;
  •    }
  •    ?>
  •    <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);
  •   if($_REQUEST['clear']) {
  •    $show0 = null;
  •    $show1 = null;
  •    $price = null;
  •   }
  •  }
  •  ?>
  •  <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</label>
  •    <br />
  •    <br />
  •    <input type="text" name="show1" value="<?php echo $show1; ?>" />
  •    &nbsp;&nbsp;
  •    <label>The end data</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 />
  •    <input type="submit" name="res" value="Calculate" />
  •    <br />
  •    <br />
  •    <input type="submit" name="clear" value="&nbsp;&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;&nbsp;" />
  •    <br />
  •    <br />
  •   </fieldset>
  •   <br />
  •   <fieldset>
  •    <legend>The sum of electricity</legend>
  •    <br />
  •    <?php
  •    if($_SERVER['REQUEST_METHOD']=='POST' && $_REQUEST['res'] && !$_REQUEST['clear']) {
  •     echo 'Sum = ', '<b>', $E->Sum(), '</b>';
  •    }
  •    else {
  •     echo null;
  •    }
  •    ?>
  •    <br />
  •    <br />
  •   </fieldset>
  •  </form>
  • </body>
  • </html>