Jump to content

php and javascript


alin19

Recommended Posts

can php and javascript be mixet? 

 

e meen something like this

 

<html>

 

 

 

<body>

 

<script language="Javascript" type="text/javascript">

<!--

var ion ='ion'

alert ('clientul este:' + ion)

 

-->

</script>

</body>

</html>

 

 

 

 

 

 

<html>

<body>

 

<script language="Javascript" type="text/javascript">

<!--

var ion ='ion'

alert ('clientul este:' + <?php echo  "ion"; ?>)

 

-->

</script>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/88894-php-and-javascript/
Share on other sites

can i do something like this?:

 

<html>

 

 

 

<body>

 

 

 

<script language="Javascript" type="text/javascript">

<!--

<?php for($i=1;$i<5;$i++)

echo <<<EOF

alert ('clientul este:' +

EOF;

echo $i;

echo ")";

?>

 

-->

</script>

</body>

</html>

 

 

 

i want that the numbers in the alert window to change;

 

 

Link to comment
https://forums.phpfreaks.com/topic/88894-php-and-javascript/#findComment-455334
Share on other sites

<html>
<body>
<script language="Javascript" type="text/javascript">
<!--
<?php
  for($i=1;$i<6;$i++)
    echo "alert ('clientul este:' +  $i );\n";
?>
-->
</script>
</body>
</html>

 

Update: I added a semicolon and a new line character at the end of JavaScript alert(). Before, it would have printed:

...
alert ('clientul este:'+ 1)alert ('clientul este:'+ 2)alert ('clientul este:'+ 3)alert ('clientul este:'+ 4)
...

which is not valid JavaScript

Link to comment
https://forums.phpfreaks.com/topic/88894-php-and-javascript/#findComment-455386
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.