Jump to content
  • Advertisement
Sign in to follow this  
Hernanduer

JS to PHP

This topic is 4076 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
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 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!