porta325 Posted March 12, 2008 Share Posted March 12, 2008 Hey guys, i have a small dependant menu but after the page reloads to populate the second listbox the first lisbox returns to original value.I need to keep that value after the form is submited.This is a code sample: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function mySubmit() { // assign our form to object f var f = document.forms.myForm; f.submit(); } </script> </head> <body> <?php mysql_connect("localhost","root",""); mysql_select_db("test"); $result=mysql_query("select * from jud"); ?> <form method="get" name="myForm" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name="judet" onChange="javascript:mySubmit();"> <option>Please select</option> <?php while($row=mysql_fetch_array($result)){ $judet=$row['judet']; echo "<option>"; if (!isset($judet)){ echo $_GET['judet']; } else echo $judet; echo "</option>"; } ?> </select> </form> <form action="x.php" name="myFormSubmit" method="post"> <?php $judet=$_GET['judet']; $result1=mysql_query("select * from orase where id_oras = '$judet'"); ?> <select name="oras"> <?php while($row=mysql_fetch_array($result1)){ $oras=$row['oras']; echo "<option>"; echo $oras; echo "</option>"; } ?> </select> <input name="Submit" type="submit" value="GO" /> </form> </body> </html> Would apreciate any ideea.thanks Link to comment https://forums.phpfreaks.com/topic/95796-keep-value-after-form-submit/ Share on other sites More sharing options...
revraz Posted March 12, 2008 Share Posted March 12, 2008 session? Link to comment https://forums.phpfreaks.com/topic/95796-keep-value-after-form-submit/#findComment-490424 Share on other sites More sharing options...
porta325 Posted March 12, 2008 Author Share Posted March 12, 2008 Problem is that result page after submit is the same file. Link to comment https://forums.phpfreaks.com/topic/95796-keep-value-after-form-submit/#findComment-490429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.