hi guys,

somebody help me please i need to know how to retain any input on page reload. I have 2 chained combo box (province and city) when a user choose a province, the next combobox should be populated. I use a script that reload the form to execute a query that filters the cities under that province. I was able to do that but the input data were gone on reload. do anyone have a sample code that will retain all the input data?

thanks in advance

put it in a session variable.

Hey, It is easier if you show us a sample of your script source, so we could help. However

Assuming I have this two elements


<form action="<php echo $_SERVER[PHP_SELF] ; ?>" method="post">

<select name = "cboCity">
<option selected="selected" value="-1"> Choose City</option>
<option value="Ohio" >Ohio</option>
<option value="Denver">Denver</option>
</select>

<input type="submit" name="push" value="submit">
</form>

Then my Php code may look like:
<?php
require "form_class.php" ;

if(array_key_exists("push",$_pos,)){
if($_POST["cboCity"] == "-1")){

echo "<div id='error'> You have not selected a city!</div>";
//Call my Print form function
$formdisp = new form ;
$formdisp ->displayform($_POST["cboCity"]) ;


}

}

?>

I am been a bit OOP Compliant here and assume that you have a form class which you created and invoke. don't mind my MVC paradigm.

hope this helps else post ur script for me here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.