I have got a form (php in html or the other way around). Once user selects an option in a drop down list, it would get the input value and create a few text boxes. It seems like I have to use onchange(). How do I read the input and perform logics within the script inself? Instead of opening another .php script?
Currently this is what I have.
<?php
$tables = $_POST["tables"];
?>
<html>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Table Name: <div id="tables">
<select name="tables">
<option value="Applications">Application</option>
<option value="Device">Device</option>
</select>
</div>
</form>
<?
echo "".$tables."";
?>
onchange()event is JavaScript, not PHP. As @nickb said in his answer, PHP doesn't know anything has changed until the user submits the form. Also, it's never a good idea to use$PHP_SELFin a form like that, it opens you up to XSS attacks. I always just hard-code the page name (for example, if this page was named tables.php:<form action="tables.php" method="post">), it is a pain to have to update it when you rename a page but it's not that big a deal.