[FX.php List] PHP and Javascript?

Charles Ross chivalry at mac.com
Sun Dec 18 16:17:13 MST 2005


Steve,

This sounds perfect! I'll have to read the documentation to be sure,  
but it seems like this will be exactly what I need.

Thanks so much!

Chuck

On Dec 17, 2005, at 9:42 AM, Steve Hannah wrote:

> Try looking into the PEAR class HTML_QuickForm (http://pear.php.net/ 
> package/HTML_QuickForm).  There is a good tutorial for QuickForm at  
> http://www.thelinuxconsultancy.co.uk/quickform.php .   Using  
> quickform you can do everything in PHP and the necessary javascript  
> is automatically generated.
>
> A brief example to get the idea:
>
>       require_once "HTML/QuickForm.php";
>       $form = new HTML_QuickForm('frmTest', 'get');
>
>       $main = array();
>       $secondary = array();
>
>       $main[0] = "England";
>       $main[1] = "Scotland";
>       $main[2] = "USA";
>
>       $secondary[0][0] = "London";
>       $secondary[0][1] = "Manchester";
>       $secondary[0][2] = "Liverpool";
>       $secondary[1][3] = "Edinburgh";
>       $secondary[1][4] = "Glasgow";
>       $secondary[2][5] = "Fort Worth";
>       $secondary[2][6] = "Boston";
>       $secondary[2][7] = "Los Angles";
>
>       $sel =& $form->addElement('hierselect', 'location',  
> 'Location:');
>       $sel->setMainOptions($main);
>       $sel->setSecOptions($secondary);
>       $form->addElement('submit', 'btnSubmit', 'Submit');
>
>       if ($form->validate()) {
>           // Form is validated, then processes the data
>           $form->freeze();
>           $form->process('process_data', false);
>       }
>       else {
>           $form->display();
>       }
>
>       function process_data ($values) {
>           echo "<pre>";
>           var_dump($values);
>           echo "</pre>";
>       }
>
> (Example taken from http://www.thelinuxconsultancy.co.uk/ 
> quickform.php).
>
> The above would produce a form with 2 select lists. The first one  
> selects countries, and the second selects cities.  When you select  
> a country, the options in the cities select list change to reflect  
> the cities of the selected country.
>
> Personally I use Quickform for nearly all forms that I do now.  It  
> keeps things much clearner.
>
> Hope this helps.
>
> Steve Hannah
>
> On 17-Dec-05, at 2:59 AM, Charles Ross wrote:
>
>> Is it possible to get a PHP array to a JavaScript function?
>>
>> I'm trying to populate a menu based on the selection for another  
>> menu. Basically it's a parent/child relationship. The user selects  
>> the parent from one menu and the children of that parent appear in  
>> a second menu.
>>
>> Getting the data from the database is done with PHP. Changing the  
>> second menu would be done, I think, with JavaScript (which I'm  
>> also learning as I go). I've been trying to figure out how to get  
>> the data from one to the other, but haven't succeeded.
>>
>> Or perhaps I'm going about this in entirely the wrong way. Any  
>> assistance would be appreciated.
>>
>> Thanks,
>> Chuck Ross
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

Chuck Ross
Author - The Book of AppleScript Studio
Contributor/Technical Editor - The Book of FileMaker
Contributing Editor - About This Particular Macintosh
Contributing Writer - ISO FileMaker Magazine
mailto:chivalry at mac.com
AIM:mer0dyn
web:http://homepage.mac.com/chivalry/




More information about the FX.php_List mailing list