JS to PHP

Started by
0 comments, last by Omega147 16 years, 10 months ago
Here's my problem. I'm trying to make a standard input box (using &#106avascript) where you would insert a number and that number would then be sent to an array in PHP, or make it's own array. What would be the code to do this or what else should I do? (My main objective is to subtract this number from another larger number)
-------------------------"Feel the Matrix"
Advertisement
To do what you're asking, you would have to pass the variable to a page containing the PHP code (via a submit button with a form, for example). Or, if you want to do it dynamically without any page refreshing, you could implement AJAX.

Another way to do it dynamically would be to initialize some &#106avascript variables with the values contained in the PHP array when the page is loaded, and then you could pass the user's input into a JS function and calculate the result there. However, this implies that you know the values in the PHP array ahead of time, which you may or may not have.

This topic is closed to new replies.

Advertisement