Linked Questions
12 questions linked to/from Get variable from PHP to JavaScript
795
votes
21
answers
1.1m
views
How do I pass variables and data from PHP to JavaScript?
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(); // ...
0
votes
3
answers
8k
views
Using a javascript variable to set PHP variable [duplicate]
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 ...
3
votes
3
answers
2k
views
Is using a PHP defined variable in javascript possible? [duplicate]
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/...
-2
votes
5
answers
3k
views
How can I set a javascript boolean variable by a php variable? [duplicate]
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 ...
0
votes
2
answers
4k
views
how to get element id of div and appendChild html to it
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 ...
-8
votes
2
answers
5k
views
How to get Client Ip address in Javascript and jQuery? [duplicate]
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 ...
0
votes
4
answers
2k
views
How to insert a variable in a js file from a html file using javascript? [duplicate]
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 ...
0
votes
3
answers
159
views
Use array values from PHP in Javascript [duplicate]
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 ...
0
votes
2
answers
85
views
Passing JSON directly to Javascript without JSON.parse()
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 ...
0
votes
1
answer
83
views
Get php variable in JavaScript [duplicate]
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&...
1
vote
2
answers
86
views
Use php variable FROM a DB for JavaScript?
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 ...
-3
votes
1
answer
45
views
Javascript Function Not Defined contactAdvertiser
<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">
&...