Jump to content

Form doesn't submit? Why?


TeddyKiller

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/199777-form-doesnt-submit-why/
Share on other sites

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();">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.