TeddyKiller Posted April 26, 2010 Share Posted April 26, 2010 I've got a form, in the footer. It uses PHP to populate the options. I click on an option.. and it doesn't submit the form. Why? I tried moving the javascript outside of the form.. and it still doesn't work. Any ideas? <div id="footer"> <form action="" name="languageform" method="post"> <select name=\"language\" id=\"language\" onchange=\"javascript: submitform()\"> <option value=\"\">Language: </option> <?php $query = mysql_query("select * from `languages`"); while($row = mysql_fetch_assoc($query)) { echo '<option value=\"'.$row['language'].'\">'.ucwords($row['language']).'</option'; } ?> </select> <script type="text/javascript"> function submitform() { document.languageform.submit(); } </script> </form> </div> Bonus question.. after that works, how would I do a validation of that form in the header? Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 26, 2010 Author Share Posted April 26, 2010 Oh damn.. the select menu had the slashes, must of thought I was going to echo it.. The javascript slightly changed to document.forms["languageform"].submit(); Now how would I validate..? Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 26, 2010 Share Posted April 26, 2010 Now how would I validate..? 1. Create a function(s) to do the validations. In addition to including appropriate alert() messages for validation failures, the function should return a true or false based on whether validation passes. 2. In the FORM tag add an onsubmit trigger such as <form action="" name="languageform" method="post" onsubmit="return validateFunction();"> Quote Link to comment 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.