Jump to content

Keep value after form submit


porta325

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.