how to access accessing PHP variable in JavaScript

Reply

Join Date: Feb 2005
Posts: 2
Reputation: techie is an unknown quantity at this point 
Solved Threads: 0
techie techie is offline Offline
Newbie Poster

how to access accessing PHP variable in JavaScript

 
0
  #1
Mar 4th, 2005
hi,
iam doing a project.
i have a problem that is "how to access PHP variable in Javascript".
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: how to access accessing PHP variable in JavaScript

 
1
  #2
Mar 4th, 2005
The simplest way is to have php write the info you want into the page as javascript, for ex:

  1. <script type="text/javascript" language="javascript">
  2. <!--
  3. <?php
  4. echo("firstVar = $var1;");
  5. echo("2ndVar = $var2;");
  6. ?>
  7. // -->
  8. </script>
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 1
Reputation: hetalsagar is an unknown quantity at this point 
Solved Threads: 0
hetalsagar hetalsagar is offline Offline
Newbie Poster

Re: how to access accessing PHP variable in JavaScript

 
0
  #3
Jan 5th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to access accessing PHP variable in JavaScript

 
0
  #4
Jan 5th, 2008
You just bumped into a 2+ yr old thread !
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 2
Reputation: samina shaikh is an unknown quantity at this point 
Solved Threads: 0
samina shaikh samina shaikh is offline Offline
Newbie Poster

Re: how to access accessing PHP variable in JavaScript

 
0
  #5
Feb 29th, 2008
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..
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 2
Reputation: samina shaikh is an unknown quantity at this point 
Solved Threads: 0
samina shaikh samina shaikh is offline Offline
Newbie Poster

Re: how to access accessing PHP variable in JavaScript

 
0
  #6
Feb 29th, 2008
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..
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1
Reputation: Cilice11 is an unknown quantity at this point 
Solved Threads: 0
Cilice11 Cilice11 is offline Offline
Newbie Poster

Re: how to access accessing PHP variable in JavaScript

 
0
  #7
Jan 14th, 2009
Originally Posted by samina shaikh View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC