Page 1 of 1

Other probs to pass variable from php to js

Posted: Sat May 25, 2013 4:21 pm
by brasileottanta
Hi ,

I have also this probs to pass a variable :
 
<?php
$ip=$_POST['ip'];
?>

<script>
............
var unbinding = document.getElementById('unbind');
unbinding.innerHTML = '<iframe src="http://xxxxx/binding-off.php?ipclient=$ip"  "width="1" height="1"></iframe>';
.......
</script>
If i use a static value like 192.168.0.250 inside innerHTML the code work . If i use a variable $ip ( passed from other php code ) don't work. Again sintax probs ?


Thanks in advance.

brasileottanta

Re: Other probs to pass variable from php to js

Posted: Sat May 25, 2013 4:26 pm
by boen_robot
Yep.

You must trigger PHP with "<?php" to access PHP variables:
<?php
$ip=$_POST['ip'];
?>


unbinding.innerHTML = '<iframe src="http://xxxxx/binding-off.php?ipclient=<?php echo $ip; ?>"  "width="1" height="1"></iframe>';

Re: Other probs to pass variable from php to js

Posted: Sat May 25, 2013 4:50 pm
by brasileottanta
Yep.

You must trigger PHP with "<?php" to access PHP variables:
<?php
$ip=$_POST['ip'];
?>


unbinding.innerHTML = '<iframe src="http://xxxxx/binding-off.php?ipclient=<?php echo $ip; ?>"  "width="1" height="1"></iframe>';
Thanks.:-) It's incredible how complex is the sintax . When all job work , I traslate in native PHP .

Regards

brasileottanta