orgzchaos Posted February 25, 2012 Share Posted February 25, 2012 <?php if (isset($_POST['checking'])) { echo $_POST['checking']; } if (isset($_POST['test'])) { echo $_POST['test']; } ?> <form id="testform2" action="testform.php" method="post"> <select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select> <input type="text" name"test" id="test"> <a href="#" onclick="this.form.submit()">submit it!</a> </form> It works when I try to submit by selecting a new value from the dropdown box but when I try to click the link it won't display the text field value. That is a test case for a problem I m having in one of my codes. Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/ Share on other sites More sharing options...
AyKay47 Posted February 25, 2012 Share Posted February 25, 2012 <input type="text" name"test" id="test"> needs to read: <input type="text" name="test" id="test"> instead of name"test" it needs to be name="test" Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321137 Share on other sites More sharing options...
orgzchaos Posted February 25, 2012 Author Share Posted February 25, 2012 That is not the problem, I just made a mistake while making a test case for the forums. Code on the actual file is fine and still not working. I just tried the following code and no results: <?php if (isset($_POST['checking'])) { echo $_POST['checking']; } if (isset($_POST['test'])) { echo $_POST['test']; } ?> <form id="testform2" action="testform.php" method="post"> <select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select> <input type="text" name="test" id="test"> <a href="#" onclick="this.form.submit()">submit it!</a> </form> Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321170 Share on other sites More sharing options...
Drummin Posted February 25, 2012 Share Posted February 25, 2012 Got the javascript to back this up? Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321180 Share on other sites More sharing options...
orgzchaos Posted February 25, 2012 Author Share Posted February 25, 2012 I am using the same function for the onChange condition of the drop down menu and it is working fine. Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321181 Share on other sites More sharing options...
Drummin Posted February 25, 2012 Share Posted February 25, 2012 How about <a href="#" onclick="testform2.submit()">submit it!</a> I would also add a blank selection so you can select "5". <select name="checking" onchange="this.form.submit()"> <option value="">-</option> <option value="5">5</option> <option value="6">6</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321185 Share on other sites More sharing options...
orgzchaos Posted February 25, 2012 Author Share Posted February 25, 2012 Worked. Is there any way to differentiate between the two submits on the server side? i.e. the receiving ( or action ) php script knows how the form was submitted i.e. either through the onchange or onclick? I know it is unlikely but still it may be useful if there was some way. Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321197 Share on other sites More sharing options...
Drummin Posted February 25, 2012 Share Posted February 25, 2012 I don't think there is a difference as both are submitting the form. Personally I would get rid of the OnChange line of the select as that is very annoying if you haven't filled out the text field yet. Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321202 Share on other sites More sharing options...
orgzchaos Posted February 25, 2012 Author Share Posted February 25, 2012 Code I have shown is just a test case for the actual scenario and the onchange function is a necessary feature for that. Quote Link to comment https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321205 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.