Q:

Javascript "submit(); " Function not found error

I have Form as
<form name="selectdoctype" method="post" action="" id="selectdoctype">
<table style="border:none;">
<tr><td colspan="2"> (<span class="asterisk" style="color:#FF0000;">*</span>) Mandatory</td></tr>
<tr>
    <td style="border-right:none">Document Name:</td>

    <td style="border-right:none">
        <input type="text" name="doc_name" value="" /><span class="asterisk" style="color:#FF0000;">*</span>
    </td>
</tr>
<tr>
    <td style="border-right:none">Document type:</td>
    <td style="border-right:none">
    <select name="doctype_id" onchange="doPaymentfor(this.value);"><option value="-1" >--Select Document Type--</option>
        <?php 
        foreach($arr_createdoc as $doctype){
        ?>
        <option value="<?php echo $doctype['doctype_id'];?>"><?php echo $doctype['doctype_name'];?></option>
        <?php }?>
    </select>
    </td>
</tr>

<tr>
    <td style="border-right:none" id="purchaselabel"></td>
    <td style="border-right:none">
    <select name="purchasedoc_id" id="purshasedocs" style="display:none;"><option value="-1" >--Select Document Type--</option>
        <?php 
        foreach($arr_purchasedoc as $docpurchase){
        ?>
        <option value="<?php echo $docpurchase['doc_id'];?>"><?php echo $docpurchase['doc_name'];?></option>
        <?php }?>
    </select>
    </td>
</tr>

<tr>
    <td style="border-right:none">Document Distribution:</td>

    <td style="border-right:none">
        <select name="distribution_id">
         <option value="-1">---Select Distriution---</option>
         <?php foreach($arr_distribution as $distribution){?>
         <option value="<?php echo $distribution['distribution_id'];?>"><?php echo $distribution['distribution_name'];?></option>
         <?php }?>
        </select>
    </td>
</tr>
<tr>
    <td colspan="2" align="center" style="border-right:none">
        <input type="button" name="submit" value="Proceed" class="submit" onclick="valdocAddEdit(this.form);"/>
    </td>
</tr>   
</table>
</form>

and javascript function as
function valdocAddEdit(frm) {
        if ((frm.doc_name.value == null) || (frm.doc_name.value == "")) {
            alert("Please enter Document Name!")
            frm.doc_name.focus()
            return false;
        }

        if(frm.doc_name.value.length > 50) {
            alert("Document Name can not be more than 20 characters!");
            frm.doc_name.focus();
            return false;
        } 

        if(frm.doctype_id.value == "-1") {
            alert("Please Select Document Type Name!");
            frm.doctype_id.focus();
            return false;
        } 

        if(frm.doctype_id.value == "1") {
            if(document.getElementById('purshasedocs').style.display == "block"){
                if(frm.purchasedoc_id.value == "-1"){
                    alert("Please Select Purchase Order Name!");
                    frm.purchasedoc_id.focus();
                    return false;
                }
            }
        } 

        if(frm.distribution_id.value == "-1") {
            alert("Please Select Distribution Name!");
            frm.distribution_id.focus();
            return false;
        } 
        frm.submit();

    }

But whenever all the javascript validation is verified the form doesnot get submitted as yields a javascript error as 
" frm.submit is not a function" in firebug.
Could some one suggest me where the code is going wrong?

A:

You are not specifying form correctly.
Quick Fix:
Just below this line:
function valdocAddEdit(frm) {

Put:
var frm = document.getElementById('selectdoctype');

Meaning:
function valdocAddEdit(frm) {
  var frm = document.getElementById('selectdoctype');
  .........
}

And now frm.submit(); shouldn't complain.

