Linked Questions

795 votes
21 answers
1.1m views

I have a variable in PHP, and I need its value in my JavaScript code. How can I get my variable from PHP to JavaScript? I have code that looks like this: <?php $val = $myService->getValue(); // ...
Madara's Ghost's user avatar
0 votes
3 answers
8k views

Possible Duplicate: Get variable from PHP to JavaScript Access a JavaScript variable from PHP I currently have this line of code: displaystatus('CALLER IS: '+inCallingNum); which is being used ...
Daniel H's user avatar
  • 2,945
3 votes
3 answers
2k views

Is it possible to use in javascript a variable that was defined in earlier PHP code? For example (in a page template PHP file): <?php $arr = array(-34, 150); ?> <script type="text/...
user avatar
-2 votes
5 answers
3k views

I have some information from my db that is being loaded onto my page, but I would like to be able to use an if statement regarding the value of this, and then assign a javascript value to be a boolean ...
fchuygy's user avatar
0 votes
2 answers
4k views

I want to get the ID of a div using JavaScript that runs inside that div. I want to appendChild() html to that div. eg: <div id="randomnumber"> <script type="text/javascript"> var ...
Binh Nguyen's user avatar
  • 1,313
-8 votes
2 answers
5k views

Possible Duplicate: Get Client IP using just Javascript? i am developing a online chat application, for that i have a server with static ip. i want to give only small javascript to include in ...
G V S Vinayak's user avatar
0 votes
4 answers
2k views

I'm using the Rain.tpl templating engine for my website. I now have a variable ($username) which I can use in my regular html file with {$username}. This works fine. I now want to use this same ...
kramer65's user avatar
  • 54.5k
0 votes
3 answers
159 views

I want to perform javascript functions on a page after I retrieve some values from a local database. However once the PHP code is in my javascript the javascript function won't even run in the first ...
Chibueze Opata's user avatar
0 votes
2 answers
85 views

I noticed that many people are passing objects from PHP to Javascript as JSON like this: var obj=JSON.parse('<?php echo json_encode($obj) ?>'); or var obj=jQuery.parseJSON('<?php echo ...
Leo Jiang's user avatar
  • 26.6k
0 votes
1 answer
83 views

I'm writing mostly in PHP, but one function requires me to use JavaScript. I need to access a PHP variable in my JavaScript. I've placed the following code between the <head> tags: <script&...
Rob Landauer's user avatar
1 vote
2 answers
86 views

I have a question. I get a variable from a DB lets call it carnumber with: $data = mysql_fetch_array($result); then to see the carnumber: echo $data["carnumber"]; And now i need this carnumber in a ...
manuzi1's user avatar
  • 1,158
-3 votes
1 answer
45 views

<script src="https://cdn.jsdelivr.net/sweetalert2/6.3.2/sweetalert2.min.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/sweetalert2/6.3.2/sweetalert2.min.css"> &...
Melon's user avatar
  • 11