Forum Moderators: coopster

Message Too Old, No Replies

java script in php

java script in php

         

Imy_S3

3:07 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



Hi

Got following java script code, but when i embed it within my php script keep getting errors.

How do it do it so i dont get errors

function myFunction()
{
f = document.forms[0];
f.result.value = f.childPrices.value * 10;
}

Birdman

4:38 pm on Mar 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just make sure you are not in PHP mode. Without knowing what error(s) you are getting or how you are embedding the script, it's hard to say.

<?php
php code here
?>
<html>
<head>
<script type="text/javascript">
your function here
</script>
<?php
more PHP here if needed
?>

mbcx9rvt

2:08 am on Mar 19, 2004 (gmt 0)

10+ Year Member



What birdman says is totally correct. PHP cannot understand standard javascript syntax and so you have to delimit the two languages.

Make sure you are escaped from PHP mode before you start in javascript!

Good luck and HTH

mbcx9rvt