I'm really confused, this is what i do:
controller:
$this->set('flag', 1);
view:
<script type="text/javasctipy">
var flag = "<?php echo $flag; ?>";
alert(flag);
</script>
On Feb 4, 2008 5:12 PM, peterhf <[EMAIL PROTECTED]> wrote:
>
> 0 or 1 depending on the value in set().
>
> Peter -
>
> On Feb 4, 10:54 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > try a pr($flag); and see what you get
> >
>
> > On Feb 4, 2008 4:51 PM, peterhf <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > The html is being rendered as though the flag variable was 0 even
> > > though is set to 1 in the controller.
> >
> > > Peter -
> >
> > > On Feb 4, 10:45 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > render the page using your favorite browser, then use the browser's
> > > > "view source" function to see what you get. Then paste here if
> > > > required.
> >
> > > > On Feb 4, 2008 4:43 PM, peterhf <[EMAIL PROTECTED]> wrote:
> >
> > > > > I don't quite understand your question. The "flag" value, 1 or 0, is
> > > > > used in the JS to toggle the display or not to display a div in the
> > > > > html of the view.
> >
> > > > > Peter -
> >
> > > > > On Feb 4, 10:36 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > > > and what did you get rendered in the html?
> >
> > > > > > On Feb 4, 2008 4:31 PM, peterhf <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > I am trying to pass a value created in a controller to a JS on the
> > > > > > > target view.
> >
> > > > > > > $this->set('flag', 1); is in the controller.
> >
> > > > > > > var flag = <?php echo $flag ?>; is in the JS. I have also tried
> > > > > > > <?=
> > > > > > > $flag ?> and <?php print($flag) ?>.
> >
> > > > > > > An alert($flag); statement in the JS displays nothing.
> >
> > > > > > > A search of this subject on Google retrieves numerous posts
> > > > > > > stating
> > > > > > > that this works in non-CakePHP PHP code.
> >
> > > > > > > What am I doing wrong?
> >
> > > > > > > Using CakePHP 1.1.13.4450.
> >
> > > > > > > Thanks for an help offered.
> >
> > > > > > > Peter -
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---