is there any method by which i can convert javascript variables to php variables
17 12478
Most of the begginers try to do this?
It doesn't make any sense assigning javascript variables to PHP variables. You can pass the values of javascript variables to a PHP script, where you can get those values into PHP variables. There are different ways of passing values from client (browser) to PHP script
Could you explain in what situation you would need to do this?
Thanks.
Atli 5,058
Expert 4TB
is there any method by which i can convert javascript variables to php variables
Javascript can not interact with PHP directly.
This is due to the fact that Javascript is run on the client's browser (client-side) while PHP is executed on the server (server-side).
So, before your Javascript code is even read by the browser, all of the PHP code will already have been executed by the server.
There are two ways to have Javascript communicate with PHP.
Either you have to refresh/redirect the page, sending along the data via the POST or GET protocols.
Or, you can use AJAX.
I would still be very careful when using data sent by Javascript. As it is generated by the client's browser, it can easily be manipulated before it is sent.
Make sure you validate it before you use it.
Not,
u can use php variable in javscript but cant use javascript variable in PHP because php can not parrsing the javascript value....
Regards,
Sandeep agarwal
..u can use php variable in javscript ...
How ?
Atli 5,058
Expert 4TB
How ?
I'm guessing hes talking about just echoing PHP values into the Javascript code?
For the record, using that method, the Javascript code is in fact not using a PHP variable. The PHP code is used to create a Javascript variable, which Javascript can then use.
"Converting" a variable from JavaScript to PHP or vice versa is kind of like trying to "convert" a 20-Euro note into a butternut squash. You have to go through the grocer, or else you're bound to get some funny looks.
And for 20 Euros, it better be one heckuva butternut squash. I'd say this is about the point where the analogy breaks down.
Anyway, PHP is executed on the server side, whereas JavaScript works on the client side, and the two *never talk to each other*.
In fact, PHP technically doesn't even know that the User's computer even exists; the HTTP server handles all those details.
PHP can output JavaScript code that (once the User's browser executes that code) will create a JavaScript variable with a particular value.
You can also pass parameters in an HTTP request that PHP converts into elements in the $_GET superglobal.
But the "conversion" process has to be done in a roundabout way because, as noted before, PHP and JavaScript don't talk to each other, and in fact, they are not even aware of each other's existence.
Atli 5,058
Expert 4TB
"Converting" a variable from JavaScript to PHP or vice versa is kind of like trying to "convert" a 20-Euro note into a butternut squash. You have to go through the grocer, or else you're bound to get some funny looks.
Brilliant analogy :)
Although I am not really sure what a butternut squash is.
Brilliant analogy :)
Although I am not really sure what a butternut squash is.
Squtterbut Nash!
Atli 5,058
Expert 4TB
wow.. that thing looks dangerous :P
Actually, it is quite tasty! The meat is like pumpkin, just a bit more compact. Great for stews and it gives a bit of a flare to stir fry.
Actually, it is quite tasty! The meat is like pumpkin, just a bit more compact. Great for stews and it gives a bit of a flare to stir fry.
I don't like pumpkin
Actually, it is quite tasty! ....
Agreed .
From javascript variables in PHP, to Butternut Squash.
Just another day on Bytes.com
I don't like pumpkin
That's a shame. It's one of the staples in the rurals areas (where I grew up). Gives a lots of energy was easy (read cheap) to get since we grew them in our maize fields.
Poor OP, here we are talking about mini-pumpkins instead of Javascript and PHP.
But those who "don't like pumpkin" should try this squash. It is quite good in Thai, Phillippine and Chinese recipes. It has a more refined taste than pumpkin and holds its form better when cooked.
...But those who "don't like pumpkin" should try this squash. It is quite good in Thai, Phillippine and Chinese recipes. It has a more refined taste than pumpkin and holds its form better when cooked.
Tastes even better in margarine.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nige |
last post by:
Is it possible to convert an item of form field data to uppercase using
the toUpperCase() method?
What I'm really asking is, how do I reference the data item?
--
Nige
Please replace YYYY...
|
by: jose.jeria |
last post by:
I use the following to convert uppercase to lowercase:
translate($queryString, 'ABCDE...', 'abcde...')
But how can i convert the case for umlauts? φεδ etc
|
by: barry |
last post by:
I have the following:
function(NAMED)
{
sString.Append("document.forms.NAMED.style.visibility = 'hidden'")
}
and would like to convert the NAMED into the object it represents - for
example in...
|
by: pbmods |
last post by:
VARIABLE SCOPE IN JAVASCRIPT
LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN )
PREREQS: VARIABLES
First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
|
by: kmitchell00 |
last post by:
I am coding in Coldfusion MX7 and using Javascript for some of the functionality. The basic functionality I'm coding is, based on a value the user chooses from a dropdown box, I populate address...
|
by: kumuda v |
last post by:
Hi all,
How to convert a php variable into the javascript variable. I need this because i want to display the content of php variable in the textbox of html field.
With regards
|
by: sumanbangladesh |
last post by:
hi
I am new both in php and javascript. I have a javascript varialbe. But I need a php variable with the same contents.How can I do it.
thanks in advance
|
by: gubbachchi |
last post by:
Hi,
How to convert a javascript variable to php variable. Could anybody help me to do this.
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |