-1

Possible Duplicate:
How to insert PHP into jQuery?

how to insert php on jquery/javascript ? for example

php

$tot =4;

javascript

$(function()

    if( can put php here? )
    eg : if( <?php tot > 4 ?> )

i want to put the php in 'if statement' ,it`s possible?

0

2 Answers 2

1

Try:

$(function() {
  if(<?=$tot?> > 4) {
    [...]
  }
});

The <?=$tot?> part will effectively echo your $tot variable in the javascript code. Beware that if $tot evaluates to '' when converted to string, it could create a syntax error in javascript code.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use
if (<?php echo $tot; ?> > 4)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.