jimmiller96 Posted May 24, 2009 Share Posted May 24, 2009 Hi All, I am fairly new to PHP/JS/Webdev, and am struggling with the following problems. I am trying to create a form that contains/displays different tables (local, no SQL) for input depending on the user selected value of a combobox. My thought process is that once the combox changes I can simply redisplay the form with the appropriate tables. The more I look at this I believe this will require a submit to make this happen. I am already submitting to Self in order to validate some of the fields, so... Q1. Upon page reload, how can I determine if the submit is due to the onchange event rather than first load or regular submit? Q2. I assume JS is required for the onchange event since PHP is server side, but I'm not familiar with implementing this. Would you be able to provide an example of the select statement and javascript? Q3. How do I maintain the original combobox selection, as well as reassign the value in the combobox once I resubmit? I understand this isn't a simple problem, so please let me know if I am wayyyyy off base here. Any help, as well as pointers in the right direction will be greatly appreciated! Thanks, Jim Link to comment https://forums.phpfreaks.com/topic/159466-combobox-onchange-question/ Share on other sites More sharing options...
Axeia Posted May 24, 2009 Share Posted May 24, 2009 Q1 First time or repost = checking if $_POST has any value. Difference between an onchange or normal submit.. you'd have to let javascript add something special onchange before submit like, <input type="hidden" value="fromOnchange" name="fromOnchange"> Q2 <select onchange="this.form.submit()"> ( I think, bit of guesswork ) Q3 Try this out, and you can work out the rest yourself I hope. <select> <option>1</option> <option selected="selected">2</option> <option>3</option> </select> Link to comment https://forums.phpfreaks.com/topic/159466-combobox-onchange-question/#findComment-841176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.