Code: Select all
Example: if the function is Func() defined in javascript....I want to pass $x in it:
<script type="text/javascript">
function Func(x) {......}
</script>
<?php if($x==0) { ?>
<body onload="Func($x)"></body>Moderator: General Moderators
Code: Select all
Example: if the function is Func() defined in javascript....I want to pass $x in it:
<script type="text/javascript">
function Func(x) {......}
</script>
<?php if($x==0) { ?>
<body onload="Func($x)"></body>Code: Select all
<?php if($x==0) { ?>
<body onload="Func(<?php echo $x;?>)"></body>Thanks for the reply but its not working in my case...The function is message1() and variable being passed is $x. The message() function after showing an alert moves to a new url (<a href=\"usergreenroom.php?visit="v"\">) for which $x is required. Below is the code:buckit wrote:$x is a php variable so you need to call it in PHP.Code: Select all
<?php if($x==0) { ?> <body onload="Func(<?php echo $x;?>)"></body>
Code: Select all
<head>
<script language="javascript">
function message1(v)
{
alert("Being of lower level, you are not allowed to view his posts");
document.location.href='<a href=\"usergreenroom.php?visit="v"\">';
return true;
}
</script>
</head>
<?php if($x>$y) { ?>
<body onload="message1(<?php echo $x; ?>)"></body> <?php }
else {
echo $x;
?>
Thank you very much....I will definitely read javascript once again.....AbraCadaver wrote:You need to look up how to do things in JS: This should work:
[text]document.location = 'usergreenroom.php?visit=' + v;[/text]