944,025 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 89680
  • PHP RSS
Mar 4th, 2005
0

how to access accessing PHP variable in JavaScript

Expand Post »
hi,
iam doing a project.
i have a problem that is "how to access PHP variable in Javascript".
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
techie is offline Offline
2 posts
since Feb 2005
Mar 4th, 2005
1

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:

PHP Syntax (Toggle Plain Text)
  1. <script type="text/javascript" language="javascript">
  2. <!--
  3. <?php
  4. echo("firstVar = $var1;");
  5. echo("2ndVar = $var2;");
  6. ?>
  7. // -->
  8. </script>
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Jan 5th, 2008
0

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
Last edited by hetalsagar; Jan 5th, 2008 at 12:54 am. Reason: Update
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hetalsagar is offline Offline
1 posts
since Jan 2008
Jan 5th, 2008
0

Re: how to access accessing PHP variable in JavaScript

You just bumped into a 2+ yr old thread !
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Feb 29th, 2008
0

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..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
samina shaikh is offline Offline
2 posts
since Feb 2008
Feb 29th, 2008
0

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..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
samina shaikh is offline Offline
2 posts
since Feb 2008
Jan 14th, 2009
0

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..
In the php file, pass the variables you want to access into $_SESSION and then echo them as shown above.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Cilice11 is offline Offline
1 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Duplicate entry '' for key 2
Next Thread in PHP Forum Timeline: Templates in PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC