Tagged Questions
140
votes
13answers
90k 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 ...
14
votes
2answers
492 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
5answers
46k 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
328 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 ...
4
votes
6answers
31k 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 ...
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 ...
57
votes
11answers
83k 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...
...
23
votes
8answers
118k 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 ...
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 ...
10
votes
5answers
43k views
12
votes
6answers
35k 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
...
72
votes
11answers
59k 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
22k 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 ...
13
votes
5answers
15k 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';
...
12
votes
11answers
24k views
Detect exact OS version from browser
I was ondering if there is a way I can detect the exact OS version from my browser using PHP/JS/ASP?
I know I can detect the type of OS (Windows XP,Windows Vista,OS X,etc) but I need to detect the ...