This is what I have managed to piece together in a separate JS file:
- I can read the number of ingredients and directions inputted and use that to dynamically add the correct number of form elements.
- I can get the input values and create a JS array of the ingredients, and a JS array of the directions.
- I can convert the arrays to JSON.
And this is where I am stuck. I now need to somehow get that JSON from my JS to my PHP controller to use with the PHP json_decode() function, so that I get two PHP arrays that I can process in my controller along with the rest of the form inputs in my $_POST array when I submit the form.
I am looking for a strategy or set of steps that will take me from the JS to the PHP, not the actual code at this time. I would like to try to figure that out for myself if possible. I tried Googling this situation, but all provided solutions have only served to confuse. Once I have an understandable set of steps, if I get stuck I will be back here with my code for more help.
This is a learning exercise - please don’t just hand me the code yet. Thank you.