Let’s say I have a select box like this:
<select style="margin-top: 5px; width: 190px;" id="daySelect">
<option>Monday, April 1st</option>
<option>Tuesday, April 2nd</option>
<option>Wednesday, April 3rd</option>
<option>Thursday, April 4th</option>
<option>Friday, April 5th</option>
<option>Saturday, April 6th</option>
<option>Sunday, April 7th</option>
<option>Monday, April 8th</option>
</select>
I want to send some variables to php to write to a file and right after load information fom the selected dropdown (The information I’m saving/loading will be in JSON if that matters).
For example: If I’m currently on Monday, April 1st and i have a variable xyz in JSON. When I click on Tuesday, April 2nd, I want to save xyz to the server (with php) and find Tuesday’s xyz variable and load it.
I’m just wondering if this possible? And any ideas on how to approach the code on this one.
Yes the code to write to the file will be in a standard php script. You will need to use javascript to attach an onchange handler to the select box which will fire an ajax request sending data to the php page. The php page can then echo out some data which will be returned in the success handler of the ajax request allowing you to handle the returned data on the front end.
I would suggest looking into jQuery as it makes life a lot simpler.