I want to keep the values on textbox after onchange function
- by user1908045
hello i have problem with this code..I want to keep the values of the textboxes when the pageload and didnt write again the values. I have two drop down list. the First one is the country when the country selected then the page load and appear the city to select but afte the pageload the values on textbox is empty. I want to keep the values of textbox when the page load.
This is the code
<head>
<script type="text/javascript">
function Load_id() {
var Count = document.getElementById("Count").value;
var Count_txt = "?Count="
location = Count_txt + Count
}
</script>
<meta charset="UTF-8">
</head>
<body>
<div class="main">
<div class="headers">
<table>
<tr><td rowspan="2"><img alt="unipi" src="/Images/logo.jpeg" height="75" width="52"></td>
<td>University</td></tr>
<tr><td>Data</td></tr>
</table>
</div>
<div class="form">
<h3>Personal</h3><br/><br/><br/>
<form id="Page1" name="Page1" action="Form1Sub.php" method="Post">
<table style="width:520px;text-align:left;">
<tr><td><label>Number:</label></td>
<td><input type="text" required="required" id="AM" name="AM" value=""/></td>
</tr>
<tr><td><label>Name:</label></td>
<td><input type="text" required="required" name="Name"/></td>
</tr>
<?php
$host="localhost";
$username="";
$password="";
$dbName="Database";
$connection = mysql_connect($host, $username, $password) or die("Couldn't Connect to the Server");
$db = mysql_select_db($dbName, $connection) or die("cannot select DataBase");
$Count = $_GET['Count'];
echo "<tr><td><label>Country</label></td>\n";
$country = mysql_query("select DISTINCT Country FROM lut_country_city ");
echo " <td><select id=\"Count\" name=\"cat\" onChange=\"Load_id(this)\">\n";
echo " `<option>Select Country</option>\n";
while($nt=mysql_fetch_array($country)){
$selected = ($nt["Country"] == $Count)? "SELECTED":"";
echo"<option value=\"".$nt['Country']."\"". $selected." >".$nt['Country']."</option>";
}
echo " </select></td></tr>\n";
echo"<tr><td><label>City:</label></td>\n";
$q2 = mysql_query("Select id,City,Country FROM lut_country_city WHERE Country = '$Count'");
echo"<td><select name=\"SelectCity\">\n";
while($row = mysql_fetch_array($q2)) {
echo"<option value=\"".$row['id']."\">".$row['City']."</option>";
}
echo " </select></td></tr>\n";
?>
</table>
<p>
<button type="submit" id="Next">Next</button>
</form>
<form id="form1" action="index.php">
<button id="Back" type="submit">Back</button>
</form>
</p>
</div>
</div>
</body>
</html>