3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <script src="jquery-2.1.1.min.js"></script> <script> $(document).ready(function(){ $("#btnKomentiraj").click(function(){ var selectElement = document.getElementById('selectElement'), textField = document.getElementById('txtField'), textValue = textField.value, selectedValue = selectElement.value; // ne koristi se html mada bi se moglo kako se asdrzaj nebi nadopunjavao $("#divKomentari").append("<p>Komentar: " + textValue + "</p><p>Ocjena komentara: " + selectedValue + "</p>"); }); $("#btnClear").click(function(){ $("#divKomentari").empty(); }); }); </script> </head> <body> <?php $ocjene =array('lose','super','dobro'); echo 'Komentar: '; echo '<input type="text" id="txtField" style="width:200px;">'; echo '<select id="selectElement" style="margin-left:10px;">'; foreach($ocjene as $opis){ echo "<option value='{$opis}'>{$opis}</option>"; } echo '</select>'; echo '<button id="btnKomentiraj" style="margin-left:10px;">Komentiraj</button>'; ?> <div id="divKomentari"></div> </body> </html>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <script src="jquery-2.1.1.min.js"></script> <script> $(document).ready(function(){ $("#btnKomentiraj").click(function(){ var selectElement = document.getElementById('selectElement'), textField = document.getElementById('txtField'), textValue = textField.value, selectedValue = selectElement.value; // ne koristi se html mada bi se moglo kako se asdrzaj nebi nadopunjavao $("#divKomentari").append("<p>Komentar: " + textValue + "</p><p>Ocjena komentara: " + selectedValue + "</p>"); }); $("#btnClear").click(function(){ $("#divKomentari").empty(); }); }); </script> </head> <body> Komentar: <input type="text" id="txtField" style="width:200px;"><select id="selectElement" style="margin-left:10px;"><option value='lose'>lose</option><option value='super'>super</option><option value='dobro'>dobro</option></select><button id="btnKomentiraj" style="margin-left:10px;">Komentiraj</button> <div id="divKomentari"></div> </body> </html>