-2

i have a javascript variable which have some value that variable value assign to php variable how i do this thing

<script type="text/javascript">
var view = true;
var bcount=10;
var wcount=10;
var tcount=10;
</javascript>
<?php
$whitelistcount=????
?>

in this code i have no use ajax and jquery only simple javascript and core php

3
  • Most simple and quick solution except submitting hidden form is using jQuery and AJAX. Any reason you don't want to use it? Commented Jun 16, 2011 at 10:43
  • You cannot do it just like that. PHP is server side, JavaScript is client side. However, as said, it can be done using AJAX. Commented Jun 16, 2011 at 10:46
  • 3
    this question was asked over 9000 times! Commented Jun 16, 2011 at 10:48

2 Answers 2

4

You could put your value into a hidden input field of a HTML form an submit it to the server, where your PHP can deal with it.

1
  • 1
    <input type="hidden" value="whatever the hell you want" /> Commented Jun 16, 2011 at 10:43
2

JavaScript can`t comunicate with PHP directly. There are two ways - AJAX or submitting a form populated with JavaScript.

The other way is PHP comunicating with JavaScript - PHP can generate the JavaScript code inside your HTML page.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.