144
votes
13answers
94k views

Pass a PHP string to a Javascript variable (and escape newlines)

What is the easiest way to encode a PHP string for output to a Javascript variable? I have a PHP string which includes quotes and newlines. I need the contents of this string to be put into a ...
22
votes
3answers
1k views

Reference: Why does the PHP code in my Javascript not work?

Note: This is a reference question. If you see one of the many questions fitting this pattern, please close them as duplicate of this. I have this code: <script type="text/javascript"> ...
11
votes
6answers
49k views

How to pass JavaScript variables to PHP?

I want to pass JavaScript variables to PHP using a hidden input in a form. But I can't get the value of $_POST['hidden1'] into $salarieid. Is there something wrong? Here is the code: <script ...
3
votes
4answers
390 views

Events triggered by dynamically generated element are not captured by event handler

I have a <div> with id="modal" generated dynamically with the jQuery load() method: $('#modal').load('handlers/word.edit.php'); word.edit.php contains a few input element, which are loaded ...
5
votes
6answers
33k views

Access a JavaScript variable from PHP

I need to access a JavaScript variable with PHP. Here's a stripped-down version of the code I'm currently trying, which isn't working: <script type="text/javascript" charset="utf-8"> var ...
1
vote
5answers
1k views

Creating jQuery AJAX requests to a PHP function

So far when creating AJAX requests I have been posting to a separate PHP file. Is it possible to create a jQuery AJAX request that calls a PHP function rather than posts to a separate page? If you ...
2
votes
1answer
3k views

Highlight row when the checkbox is true

Can Some one help me, I have a jqgrid and I want to highlight the row if the checkbox is true, thanks!! this is what i want to make in this project... function loadjqGrid(jsonGridData){ var ...
58
votes
11answers
85k views

Resize iframe height according to content height in it

I am opening my blog page in my website. The problem is I can give a width to an iframe but the height should be dynamic so that there is no scrollbar in the iframe, and it looks like a single page... ...
27
votes
8answers
125k views

How to call a JavaScript function from PHP?

How to call a JavaScript function from PHP? <?php jsfunction(); // or echo(jsfunction()); // or // Anything else? The following code is from xyz.html (on a button click) it calls a ...
15
votes
6answers
38k views

Convert php array to Javascript

How can I convert a PHP array in a format like this Array ( [0] => 001-1234567 [1] => 1234567 [2] => 12345678 [3] => 12345678 [4] => 12345678 [5] => AP1W3242 ...
10
votes
5answers
47k views

Get variable from PHP to JavaScript

I want to use a PHP variable in JavaScript. How is it possible?
73
votes
11answers
62k views

JavaScript equivalent of PHP's in_array()

Is there a way in JavaScript to compare values from one array and see if it is in another array? Similar to PHP's in_array function?
12
votes
6answers
24k views

How to access PHP variables in JavaScript or jQuery rather than <?php echo $variable ?>

How do I access PHP variables in JavaScript or jQuery? Do I have to write <?php echo $variable1 ?> <?php echo $variable2 ?> <?php echo $variable3 ?> ... <?php echo $variablen ...
7
votes
5answers
23k views

Call php function from javascript

Is there a way I can run a php function through a js function? something like this: <script type="text/javascript"> function test(){ document.getElementById("php_code").innerHTML="<?php ...
13
votes
5answers
16k views

Best way to transfer an array between PHP and Javascript

So I have an array of records retreived from a database. The array is in the format; $rows[0]['id']=1; $rows[0]['title']='Abc'; $rows[0]['time_left']=200; $rows[1]['id']=2; $rows[1]['title']='XYZ'; ...

1 2 3 4 5 147
15 30 50 per page