0

hi,
iam doing a project.
i have a problem that is "how to access PHP variable in Javascript".

6
Contributors
6
Replies
18
Views
12 Years
Discussion Span
Last Post by Cilice11
1

The simplest way is to have php write the info you want into the page as javascript, for ex:

<script type="text/javascript" language="javascript">
<!--
<?php 
echo("firstVar = $var1;");
echo("2ndVar = $var2;");
?>
// -->
</script>
Votes + Comments
cool solution
0

hey, you can do this simple things.

function reset1()
{
//document.frmadd.intFaqCategoryTypeID.value='1';
document.frmadd.reset();
document.frmadd.intChatRoomCategoryId.value='<?php echo $intChatRoomCategoryId ; ?>';
document.frmadd.intEventId.value='<?php echo $intEventId ; ?>';
document.frmadd.intGroupId.value='<?php echo $intGroupId ; ?>';
document.frmadd.intMemberID.value='<?php echo $intAddedByMemberId     ; ?>';
return false;
}

Edited by happygeek: fixed formatting

0

i have two diffrent file php and html(includes javascript..) how can i access php variable in javascript using two seprate file .can u plz guid me..

0

i have two diffrent file php and html(includes javascript..) how can i access php variable in javascript using two seprate file .can u plz guid me..

0

i have two diffrent file php and html(includes javascript..) how can i access php variable in javascript using two seprate file .can u plz guid me..

In the php file, pass the variables you want to access into $_SESSION and then echo them as shown above.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.