Hi,

Just lose the <?php ?> tags and you're good to go. ;)

You're trying to run javascript code in the PHP interpreter, which
isn't going to work.
All you have to do is replace your code with:

<div id="mutsu" class="apple"></div>

if( $('mutsu').hasClassName("apple") ) {
       alert("div has CSS apple class.");
}

and then that code will be executed on the client.

You're confusing PHP code with Javascript code, and that's not good.

PHP is intended to be executed *on the server*, before sending a
response to the client, while Javascript is supposed to execute *on
the client browser* (although it's also possible to run javascript
server-side).

Perhaps you're confused because symfony has some javascript helpers
that should be placed inside <?php ?> tags, but these javascript
helpers are actually PHP functions, hence the tags.
When you want to write "real javascript", you should write it outside
the <?php ?> tags, or echo/print it from inside them.....


Best Regards,
--
Tiago Nunes

On Jan 15, 8:09 pm, Javier Garcia <tirengar...@gmail.com> wrote:
> Hi,
>
> I have added this in a template:
>
> <div id="mutsu" class="apple"></div>
>
> <?php  if( $('mutsu').hasClassName("apple") ){
>        alert("div has CSS apple class."); ?>
>     }
>
> but when i load the template in the browser, the javascript alert is not
> showed.
>
> Even in Netbeans i have a syntax error...
>
> I added also the code above in a file where im using another prototype
> function (toggleClassName()) that works ok to be sure the problem is not
> caused because im not loading prototype.js. This is the code i say:
>
> <?php echo link_to_remote('Marcar como leido', array(
>
>              'url' => 'mensaje/cambiarEstadoLeido?id='.$m->getId(),
>
>              // Aqui se desplegar el resultado de la acci n.
>              'update' => 'mensaje_'.$m,
>
>              "complete" => "$('$m').toggleClassName('mensaje_1');",
>
>              )); ?>
>
> Any help?
>
> Javi
-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to