lundi 30 mars 2015

keep value in textbox after page reload to itself in php?

I have two textboxes and two dropdowns in a form. After filling values in textboxes and selecting value from dropdown the page reloads and based on value selected in dropdown other dropdown gets populated. But values in textboxes is not there. How to retain these textboxes values.



<html>
<head>

</head>
<body>
<form action="selectmultiplepost.php" method="post" name="myform">

First Name<input type="text" name="firstname" value=""><br>
Last Name<input type="text" name="lastname" value=""><br>


Industry Name <select name="industryid" id="industrySelect" onchange="document.location.href = 'selectmultiple.php?industryid=' + this.value">
<option>SELECT</option>
<?php
include('config.php');

$query = "select IndustryId, IndustryName from industrytable";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
while($fetch = mysql_fetch_array($result))
{
?>
<option value="<?php echo $fetch['IndustryId'];?>"><?php echo $fetch['IndustryName'];?></option>
<?php
}
}


?>
</select><br>
Skills <select name="skillname">
<option>SELECT</option>
<?php
include('config.php');

if(isset($_GET['industryid']))
{
$industryID = $_GET['industryid'];
}
else
{
$industryID = "";
}

$skillQuery = "select SkillId, SkillName from skilltable where Industryid='".$industryID."'";
$resultSkill = mysql_query($skillQuery);
if(mysql_num_rows($resultSkill) > 0)
{
while($fetch = mysql_fetch_array($resultSkill))
{
?>
<option value="<?php echo $fetch['SkillId'];?>"><?php echo $fetch['SkillName'];?></option>
<?php
}
}

?>

</select><br>
<input type="submit" name="submitform" value="submit"/>
</form>

<script>

document.getElementById('industrySelect').value = "<?php echo $_GET['industryid'];?>";
</script>

</body>
</html>

Aucun commentaire:

Enregistrer un commentaire