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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.