html value access
Posted: Thu Jun 26, 2008 10:04 am
hi,
I am a neb with php coding, but would definitely like to learn! I am creating a simple website using php and a back frame mysql database. I have created a form with several fields using html. my question is....I want to create a case where if a user chooses option A from a dropdown box then an extra input textbox must appear instantaneosly for the user to fill.
For example. Say I have a add training from. One of the fields asks the user if the new training is internal. If the user answers no, then a new organization text field must appear immediately ( prior to submission) for the user to fill in.
this is the code I tried:
<html>
<body>
<form action = "adddTrainingTbl.php" method="post">
TrainingName
<input type="text" name = "tName">
<br>
<br>
Internal Training?
<select name="iTraining">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br>
<br>
<?php
if ($_REQUEST['itraining'] == 'No')
{
echo "Organization".'<br>'.'<br>'.'<input type="text" name="organization">';
}
?>
<br>
<br>
Cost
<input type="text" name="cost">
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
I probably know that I shoudnt be using $_REQUEST if I am not submittting the form. However, i had to try something
. Can someone please assist? Thanks!!
I am a neb with php coding, but would definitely like to learn! I am creating a simple website using php and a back frame mysql database. I have created a form with several fields using html. my question is....I want to create a case where if a user chooses option A from a dropdown box then an extra input textbox must appear instantaneosly for the user to fill.
For example. Say I have a add training from. One of the fields asks the user if the new training is internal. If the user answers no, then a new organization text field must appear immediately ( prior to submission) for the user to fill in.
this is the code I tried:
<html>
<body>
<form action = "adddTrainingTbl.php" method="post">
TrainingName
<input type="text" name = "tName">
<br>
<br>
Internal Training?
<select name="iTraining">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br>
<br>
<?php
if ($_REQUEST['itraining'] == 'No')
{
echo "Organization".'<br>'.'<br>'.'<input type="text" name="organization">';
}
?>
<br>
<br>
Cost
<input type="text" name="cost">
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
I probably know that I shoudnt be using $_REQUEST if I am not submittting the form. However, i had to try something