Sign in to follow this  

JS to PHP

This topic is 3857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's my problem. I'm trying to make a standard input box (using javascript) 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)

Share this post


Link to post
Share on other sites
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 javascript 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.

Share this post


Link to post
Share on other sites

This topic is 3857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this