Hi all,
Below is a small example snippet of an enmeshed php, html, css & js program which I think would be an example of bad programming.
Using this simple example below can someone please demonstrate how it may be used to separate the code and convert the html into a template. It would be a nice example to learn about templating I think. Thank all.
<?php
print_r($_POST);
$rooms = array(1,2,3,4);
$displayed = 2;
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#room').change(function(){
$(this).parent('form').submit();
});
});
</script>
<?php
echo "<div>";
echo "<form id = 'form1' action='#' method='post' > ";
echo "<select name='room' id='room'>";
if(isset($displayed)) echo "<option selected>".$displayed."</option>";
$i = 0;
while($i < count($rooms))
{
$room = $rooms[$i];
if($room === $displayed)echo "";
else echo "<option value = ".$room." > ".$room." </option>";
$i++;
}
echo "</select>";
echo "<noscript><input type='submit' value='Submit'></noscript>";
echo "</form>";
echo "</div>";
?>