3v4l.org

run code in 300+ PHP versions simultaneously
<!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 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<!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>

preferences:
311.66 ms | 408 KiB | 457 Q