Click here to Skip to main content
16,009,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP

selection is like
computer
mechanical
electronics
other

when "other" is selected text box should have to be appear
Posted

1 solution

Hi this is simple example , you can improve it later :)

PHP
<?php
    function dropDown()
    {
        $phpself = $_SERVER['PHP_SELF'];
        echo"<form method='post' action='$phpself'>";
        echo"<select name='categories'>";
        echo"<option value='computer'>computer</option>";
        echo"<option value='mechanical'>mechanical</option>";
        echo"<option value='electronics'>electronics</option>";
        echo"<option value='other'>other</option>";
        echo"</select>";
        echo"<input type='submit' name='submit' value='Submit Form'><br>";
        echo"</form>";
    }
?>
<?php
if(isset($_POST['submit']))
{
    $name = $_POST['categories'];
    if($name == "other"){
        echo "<form >";
        echo "<textarea name='myTextBox' cols='20' rows='1'>";
        echo "Enter some text...";
        echo "</textarea>";
        echo "<br />";
        echo "<input type='submit' ><br>";
        echo "</form>";
    }
    else{
        dropDown();
        return;
    }
}
?>
<?php
    dropDown();
?>


Hope it will help you :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900