3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<!DOCTYPE html> <html> <head lang="de"> <title>Anschrift</title> <meta charset="UTF-8"> <script type="text/javascript"> function showadressfield(participant) { if ( document.getElementById("check"+participant).checked == true ) { document.getElementById("adresse"+participant).style.display ="inline"; } else { document.getElementById("adresse"+participant).style.display ="none"; } } </script> </head> <body> <?php for ($participants=1;$participants<=5;$participants++){ echo 'Teilnehmer '.$participants.' <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check'.$participants.'" onClick="showadressfield('.$participants.')"><br> <div style="display:none" id="adresse'.$participants.'" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr>'; }; ?> </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 lang="de"> <title>Anschrift</title> <meta charset="UTF-8"> <script type="text/javascript"> function showadressfield(participant) { if ( document.getElementById("check"+participant).checked == true ) { document.getElementById("adresse"+participant).style.display ="inline"; } else { document.getElementById("adresse"+participant).style.display ="none"; } } </script> </head> <body> Teilnehmer 1 <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check1" onClick="showadressfield(1)"><br> <div style="display:none" id="adresse1" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr>Teilnehmer 2 <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check2" onClick="showadressfield(2)"><br> <div style="display:none" id="adresse2" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr>Teilnehmer 3 <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check3" onClick="showadressfield(3)"><br> <div style="display:none" id="adresse3" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr>Teilnehmer 4 <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check4" onClick="showadressfield(4)"><br> <div style="display:none" id="adresse4" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr>Teilnehmer 5 <br><input type="text" name="addresse" placeholder="Name"> <br>abweichende Anschrift <input type="checkbox" id="check5" onClick="showadressfield(5)"><br> <div style="display:none" id="adresse5" > <input type="text" name="addresse" placeholder="Adresse"><br> <input type="text" name="plz" placeholder="Postleitzahl"> </div><br><hr> </body> </html>