Welcome Guest, Not a member yet? Register   Sign In
Possible to produce a javascript function from PHP?
#2

[eluser]Crafter[/eluser]
Well, you want the Javascript code dynamically created right. One way is is embed them in an html file

Create a view result.php

Code:
function show_get_clicklist_response(response) {
    eval(response.responseText)    

YAHOO.example.container.photobox = new YAHOO.widget.PhotoBox("photobox",
                {
                    effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.45},
                    fixedcenter:true,
                    constraintoviewport:true,
                    underlay:"none",
                    close:true,
                    visible:false,
                    draggable:true,
                    modal:true,
                    photos:[
<?                foreach ($photolist as $photo ) ?>
                       {src:"http://static.flickr.com/<?= $photo['image']; ?>",caption:"<?= $photo['caption']; ?>"},
<?                } ?>
                           ],
                    width:"500px"
                } );
                YAHOO.example.container.photobox.render();
                
                YAHOO.util.Event.addListener("show", "click", YAHOO.example.container.photobox.show, YAHOO.example.container.photobox, true);
    }

Then, in your yor controller:
Code:
function getclicklist($id)
    {
    $this->load->model('Load');
    $result['photolist'] = $this->Load->getclicklist($id);      // <== NOTICE THE INDEX TO THE ARRAY
    // $result will have  :
    // array[
    //   [image] => '51/129586913_e78683c466.jpg', [caption] => 'Linus 1',
    //   [image] => '50/129590195_0642f2d96a.jpg', [caption] => 'Linus 2',
    //   [image] => '8/12669712_be928a0d97.jpg', [caption] => 'Dobb's Ferry, NY',
    // ]

    // Call the view result.php and pass $result to it
    $this->load->view('result', $result)
        
        }


Messages In This Thread
Possible to produce a javascript function from PHP? - by El Forum - 09-04-2007, 12:47 PM
Possible to produce a javascript function from PHP? - by El Forum - 09-04-2007, 01:50 PM
Possible to produce a javascript function from PHP? - by El Forum - 09-05-2007, 07:21 AM
Possible to produce a javascript function from PHP? - by El Forum - 09-05-2007, 11:04 AM
Possible to produce a javascript function from PHP? - by El Forum - 09-05-2007, 11:43 AM
Possible to produce a javascript function from PHP? - by El Forum - 09-06-2007, 04:30 AM
Possible to produce a javascript function from PHP? - by El Forum - 09-07-2007, 08:52 AM
Possible to produce a javascript function from PHP? - by El Forum - 09-07-2007, 09:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB