Forum Discussion

srinivaskiranp's avatar
7 years ago

How to submit a form when clicked input type is submit.

How to implement submit a form functionality when clicked input type submit   ?. 

 

1 Reply

  • srinivaskiranp

    html:

    <form method="post" name="form1" id="form1">    
        <input id="submit" name="submit" type="submit" value="Submit" onclick="eatFood();" />
    </form>

    Javascript&colon; to submit the form using javascript

    function eatFood() {
    document.getElementById('form1').submit();
    }

    to show on click message

    function eatFood() {
    alert('Form has been submitted');
    }