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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.