galvin Posted February 19, 2011 Share Posted February 19, 2011 This might not be enough info for anyone to help with but I'm taking a chance because I'm at my wits end. I have this relatively simple form on a page called "createquiz.php" which has a select dropdown for every row in the table which triggers the form to submit when an option is chosen. It is then sent to "move.php" to manipulate the data. The gist is that users can go to row 4 (for example) and choose "2" from the drop down menu and it will go to move.php which will then update the id of row 4 to now be 2. Basically just reordering the rows in the table. The weird thing is that when the "option" chosen has a value LESS THAN the value of $info['answerid'] for the chosen row, the form submits fine to move.php (like my example above going from 4 to 2. However, if the "option" chosen has a value GREATER THAN the value of $info['answerid'] for the chosen row (like if the user tried to move row 4 to row 7), the form doesn't submit to move.php and instead the page refreshes with a super weird URL like this... "createquiz.php?move=3&submitthisform=submit&hidden=move&numanswers=3#". I have no code anywhere the tries to build a URL anything like that, so something is going very wrong. It looks like it's taking all of the "names" from my form code below and throwing them into a URL. With this minimal info, just curious if anyone has any idea what type of problem in code could lead to this weird type of URL? FYI, the code that gets the values for $_GET['quizid'] and $info['answerid'] is not shown, but I'm positive that is all working fine so I don't think it's important in regards to this issue, especially because when the problem happens, it's not even getting to the point where it tries to post to that URL. <form method='post' action='move.php?quizid={$_GET['quizid']}&answerid=" . $info['answerid'] . "'> <select name='move' onChange='this.form.submit();'> <option value='x' >Move to...</option> "; for($i=1; $i<=$lastid;$i++) { echo "<option value='$i'>$i</option>"; } echo "</select> <input type='hidden' name='submitthisform' value='submit' /><input type='hidden' name='hidden' value='move' /><input type='hidden' name='numanswers' value='$lastid' /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/228200-inconsistent-form-issue-using-php-and-javascript/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 19, 2011 Share Posted February 19, 2011 You either have something else going on in your form, such as nested form tags, which is invalid, or the move.php page you are submitting to is redirecting back to the form with that unexpected URL. You would need to post enough working code that produces/reproduces the symptom. Just the small part you did post doesn't reproduce the problem. Quote Link to comment https://forums.phpfreaks.com/topic/228200-inconsistent-form-issue-using-php-and-javascript/#findComment-1176758 Share on other sites More sharing options...
galvin Posted February 21, 2011 Author Share Posted February 21, 2011 Not that you care, but I found that the form code I posted in this forum was inside of another unnecessary form that had a blank action and onChange='this.form.submit();' was submitting to the this other "parent" form, instead of the "child" form. I have no idea why sometimes it would submit the "child" form and sometimes it submitted the "parent" form, but I guess it's not important now, because I removed the "parent" form (which is unnecessary, at least at this point) and the everything works all the time now. Just weird. Quote Link to comment https://forums.phpfreaks.com/topic/228200-inconsistent-form-issue-using-php-and-javascript/#findComment-1177377 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.