3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<!DOCTYPE html> <html> <script type="text/javascript"> function jsfunction(chkbox, qtyloop, total) { document.getElementById(chkbox); document.getElementById(qtyloop); document.getElementById(total); if (document.getElementById(chkbox).checked) { document.getElementById(qtyloop).disabled = false; } else { document.getElementById(qtyloop).disabled = true; document.getElementById(total).innerHTML =0; } }; function QtymultiplyPrice(qty, price,total) { document.getElementById(total).innerHTML = qty * price; myvariable = document.getElementById(total).innerHTML; document.getElementById("granttotal").value += myvariable; }; </script> <body> <form action="" method="get"> <?php $item=array("A"=> array("price" => 10, "image"=>"http://image.made-in-china.com/2f0j00aecQtAECqqGP/Amon-15-Touch-POS-Monitor.jpg", "description"=>"POS Monitor"), "B"=> array("price" => 11, "image"=>"http://www3.pcmag.com/media/images/321794-lenovo-ideapad-z400-touch.jpg", "description"=>"Laptop"), "C"=> array("price" => 12, "image"=>"http://www.bensultd.com/img/items/full/gvrEVhZXf5wGam2.gif", "description"=>"POS printer"), "D"=> array("price" => 13, "image"=>"http://upload.wikimedia.org/wikipedia/commons/1/13/Barcode-scanner.jpg", "description"=>"Barcode Scanner"), "E"=> array("price" => 14, "image"=>"http://www.apipos.com/images/cf-405-m-b.jpg", "description"=>"Cash Drawer")); $var=1; $loopqty=1; $check=1; $xtotal=1; $granttotal=0; $gtotal=1; ?> <table id="table1" border=1 width='600' <tr> <th>No</th> <th>item</th> <th>Image</th> <th>Description</th> <th>Check</th> <th>Price</th> <th>Qty</th> <th>Total</th> </tr> <?php foreach($item as $myItem=>$kk){ echo "<tr>"; echo "<td>".$var."</td>"; echo "<td>".$myItem."</td>"; $price=$kk["price"]; $image=$kk["image"]; $description=$kk["description"]; ?> <td> <?php echo '<img src="'.$image.'" height=70 width=70>'; ?> </td> <?php echo "<td>".$description."</td>"; ?> <td> <input type="checkbox" name="chkbox" id="chkbox<?php echo $check; ?>" onchange="jsfunction('chkbox<?php echo $check; ?>','quantity<?php echo $loopqty;?>','total<?php echo $xtotal;?>')" /> </td> <?php echo "<td>".$price."</td>"; ?> <td> <select id="quantity<?php echo $loopqty;?>" name="quantity" onchange="QtymultiplyPrice(this.value,<?php echo $price; ?>, 'total<?php echo $xtotal;?>')" disabled="true"> <?php for($i=1;$i<=1000;$i++) { echo "<option id="."option".$loopqty." value=".$i.">".$i."</option>"; } ?> </select> </td> <td><span id="total<?php echo $xtotal; ?>" name="total">0</span></td> <?php $var++; $check++; $loopqty++; $xtotal++; $gtotal++; echo "</tr>"; } ?> <tr> <td colspan=7> Grant Total </td> <td> <input id="granttotal" type="text" name="granttotal" size =1/> </td> </tr> </table> <button onClick="window.print()">Print this page</button> <button>Reset</button> </form> </body> </html>