DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   how to access accessing PHP variable in JavaScript (http://www.daniweb.com/forums/thread19598.html)

techie Mar 4th, 2005 10:07 am
how to access accessing PHP variable in JavaScript
 
hi,
iam doing a project.
i have a problem that is "how to access PHP variable in Javascript".

DanceInstructor Mar 4th, 2005 11:40 am
Re: how to access accessing PHP variable in JavaScript
 
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>

hetalsagar Jan 5th, 2008 12:53 am
Re: how to access accessing PHP variable in JavaScript
 
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;
}

---------------------------------------------------------------------------------------------------------
u can reach me at hetalsagar@rediffmail.com

nav33n Jan 5th, 2008 2:10 am
Re: how to access accessing PHP variable in JavaScript
 
You just bumped into a 2+ yr old thread !

samina shaikh Feb 29th, 2008 3:46 am
Re: how to access accessing PHP variable in JavaScript
 
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..

samina shaikh Feb 29th, 2008 4:00 am
Re: how to access accessing PHP variable in JavaScript
 
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..

Cilice11 Jan 14th, 2009 10:57 pm
Re: how to access accessing PHP variable in JavaScript
 
Quote:

Originally Posted by samina shaikh (Post 548598)
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.


All times are GMT -4. The time now is 1:15 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC