jylaj Posted June 17, 2007 Share Posted June 17, 2007 hi, I am having dropdown menu in my php script(prva.php). In another php script (vtora.php) I have the same drop down menu but the drop down menu shows the previously selected value from the drop down menu in prva.php(from the various values that are optional to select). The problem that I have is that I want depending on the value from the drop down menu that was passed to vtora.php to select a table from my database. The code for the drop down menu in prva.php is : <form name="Meni" action="vtora.php" method="POST"> <tr> <td width="44%" align="center" valign="top" bordercolor="#00FFFF" class="A-Text-BG" id="Recnik11_Td4"> <div align="right"> <p><span class="style5">ЈАЗИК</span> <select name="Jazik" id="Jazik" style="width:25%;height:inherit" > <option selected="selected" value="none"> </option> <option value="me">Македонски-Англиски</option> <option value="em">Англиски-Македонски</option> <option value="md">Македонски-Германски</option> <option value="dm">Германски-Македонски</option> </select> </p> </div> </td> </tr> </form> <?php The code for the drop down menu in vtora.php is : <form method="post" action="vtora.php" > <?php if ($_POST["Jazik"] == "none"){echo "<option value='none' selected> </option>";}?> <?php if ($_POST["Jazik"] == "me"){echo "<option value='me' selected> Mакедонски-Англиски </option>";} else {echo "<option value='me'> Mакедонски-Англиски </option>";} ?> <?php if ($_POST["Jazik"] == "em"){echo "<option value='em' selected> Англиски-Македонски </option>";} else {echo "<option value='em'> Англиски-Македонски </option>";} ?> <?php if ($_POST["Jazik"] == "md"){echo "<option value='md' selected> Македонски-Германски </option>";} else {echo "<option value='md'> Македонски-Германски </option>";} ?> <?php if ($_POST["Jazik"] == "dm"){echo "<option value='dm' selected> Германски-Македонски </option>";} else {echo "<option value='dm'> Германски-Македонски </option>";} ?> </select> </div> </form> The code that I am using to select a table depending on the value that was passed to vtora.php(and that code doesn't seem to work Smile ) is : if ($_POST["Jazik"]=="me") {$tabela="ang_mak";} else {if ($_POST["Jazik"]=="em") {$tabela="mak_ang";}} if ($_POST["Jazik"]=="md") {$tabela="ger_mak";} else {if ($_POST["Jazik"]=="dm") {$tabela="mak_ger";}} the problem is that $_POST["Jazik"] works when displaying the selected value from prva.php in vtora.php(it remembers what was selected in prva.php) but in the code that is for choosing a database table when I do $jazik=$_POST["Jazik"]; echo "$jazik"; it returns nothing- the variable $jazik is empty and I don't know why because the code for choosing a database table is also in the vtora.php script Please give me ur valuables idea Thanks Quote Link to comment https://forums.phpfreaks.com/topic/55958-passing-value-from-a-drop-down-menu/ Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 if you use those page for same purpose try to just use php self and what are this for again?? <?php if ($_POST["Jazik"] == "none"){echo "<option value='none' selected> </option>";}?> <?php if ($_POST["Jazik"] == "me"){echo "<option value='me' selected> Mакедонски-Англиски </option>";} else {echo "<option value='me'> Mакедонски-Англиски </option>";} ?> <?php if ($_POST["Jazik"] == "em"){echo "<option value='em' selected> Англиски-Македонски </option>";} else {echo "<option value='em'> Англиски-Македонски </option>";} ?> <?php if ($_POST["Jazik"] == "md"){echo "<option value='md' selected> Македонски-Германски </option>";} else {echo "<option value='md'> Македонски-Германски </option>";} ?> <?php if ($_POST["Jazik"] == "dm"){echo "<option value='dm' selected> Германски-Македонски </option>";} else {echo "<option value='dm'> Германски-Македонски </option>";} ?> </select> </div> </form> sorry i just dont get your point Quote Link to comment https://forums.phpfreaks.com/topic/55958-passing-value-from-a-drop-down-menu/#findComment-276512 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.