[FX.php List] Javascript & PHP
Scott Baetz
sbaetz at soscs.net
Fri Sep 8 06:24:56 MDT 2006
Chuck,
I believe this is easier than you might think. First, I strongly
recommend a good web search on this matter. I've found that
www.JavaScript.com can provide a number of good leads in the right
direction.
At the core of this situation, you might ask yourself, how is this going
to be structured? Frankly you should create your two related
javascript'ed menus without PHP first (I only suggest this as you are
indicating that you are learning JavaScript as you go). With this basic
coding mastered, you will realize that as Michael mentions below, you
are simple going to load the data values from a standard FXphp call.
BAM you are done.
Best regards,
Scott Baetz
sbaetz at soscs.net
http://www.soscs.net
> Message: 6
> Date: Thu, 07 Sep 2006 23:05:33 -0400
> From: Michael Layne <fx at 9degrees.com>
> Subject: Re: [FX.php List] PHP and Javascript?
> To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
> Message-ID: <4500DDFD.5020009 at 9degrees.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Chuck,
>
> Well, here's how I populate a JavaScript array with a PHP one...
> grabbing photos that live in the file system and belong to a particular
> record ($record)
>
> <script type="text/javascript" language="javascript">
> <?
> $maindir = $_SERVER['DOCUMENT_ROOT']."/" . $site . "/photos/";
> $mydir = opendir($maindir) ;
> $c = 0;
> while($fn = readdir($mydir)) {
> if ($fn!= "." && $fn!= ".." && substr($fn, 0, 5) == $record) {
> //this condition can be anything or nothing. It's specific to my app...
> echo "Pic[" . substr($c,0,2) . "] = '../photos/" . $fn . "';\n"; //
> here's where the JavaScript array gets outputted.
> $c++;
> }
> }
> closedir($mydir);
> ?>
> </script>
>
> HTH. Let me know If I can (try) to explain anything more...
>
> Michael
>
> Michael Layne : 9 degrees development : www.9degrees.com : 404.226.7835
>
> 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
>>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060907/bfef1300/attachment.html
>
> ------------------------------
>
> _______________________________________________
> FX.php_List
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> End of FX.php_List Digest, Vol 26, Issue 11
> *******************************************
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060908/e343030a/attachment.html
More information about the FX.php_List
mailing list