0

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

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by hakimkal
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.