| | |
retain input data on page reload
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Solved Threads: 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
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
•
•
Join Date: Dec 2007
Posts: 19
Reputation:
Solved Threads: 4
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.
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.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Cron Jobs
- Next Thread: Long Date Language Translator
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube






