• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combined select with dropdown lists into the form

#1
[eluser]phpuser[/eluser]
Hello,

I've a problem which is getting me crazy, I can't find a solution for the moment.
I need to have two drop down lists combined (one which shows for example the state or province and the other the cities of the selected state). The second drop down list must be refreshed once the state has changed. I've been able to make it work having both drop down lists in a form, but the problem is that they have to appear into a form which contain other fields like name, surname, address, etc...

Anyone could help me and show what would be the changes I have to do into the following code in order to make it work ?

Code:
<?php
// User Account

if ($data_u != null) {
echo form_open('user/Update_User');    
    
echo " <p><label for='pname'>Name </label><br/>";
$data = array('name'=>'name','id'=>'pname','size'=>50, 'value' => $data_u['name']);
echo form_input($data) ." </p>";

echo " <p><label for='psurname'>Surname </label><br/>";
$data = array('name'=>'surname','id'=>'surname','size'=>50, 'value' => $data_u['surname']);
echo form_input($data) ." </p>";

echo " <p><label for='state'>State </label><br/>";
echo form_dropdown('state', $this->Mod_Utils->getStates(), $data_u['state']) ." </p>";

echo " <p><label for='city'>City </label><br/>";
echo form_dropdown('city',$this->Mod_Utils->getCities() ,$data_u['city']) ." </p>";

echo form_hidden('user_id',$data_u['user_id']);  

echo form_submit('submit','Save Data');
echo form_close();
}
?&gt;

Now $this->Mod_Utils->getStates() returns an array of all the States and
$this->Mod_Utils->getCities() returns an array of all the Cities for all the states.

Thanks !


Messages In This Thread
Combined select with dropdown lists into the form - by El Forum - 10-13-2009, 02:56 AM
Combined select with dropdown lists into the form - by El Forum - 10-13-2009, 03:37 AM
Combined select with dropdown lists into the form - by El Forum - 10-13-2009, 04:30 AM
Combined select with dropdown lists into the form - by El Forum - 10-13-2009, 07:20 AM
Combined select with dropdown lists into the form - by El Forum - 10-13-2009, 08:39 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.