Henk Z Henk Z - 3 months ago 12
Javascript Question

Form or a on click trigger submit

I currently have a code, that is loaded dynamicly, so I can not tweak it much.
But now I want to trigger the submit when clicking the entire

<form>
.

How can I achive that?

My current code:

<form action="http://example.com" method="post" target="_blank">
<input type="hidden" name="token" value="1234567890">
<input type="hidden" name="SESSID" value="1234567890">
<input type="hidden" name="PHPID" value="1234567890">
<input type="submit" value="Open Panel">
<p class="pakb-box-icon"><i class="icon-webadres"></i></p>
<h2>Manage</h2>
<p class="pakb-box-desc">TEXT</p>
<p class="pakb-view-all">TEXT</p>
</form>

Answer

Okay man, i will answer this, but on the next time you need to post your javascript code.

This is your markup:

<!-- add a id here -->
<form id="form" action="http://example.com" method="post" target="_blank">

    <input type="hidden" name="token" value="1234567890">

    <input type="hidden" name="SESSID" value="1234567890">

    <input type="hidden" name="PHPID" value="1234567890">
    <!-- add a id here -->
    <input id="submit" type="submit" value="Open Panel">

    <p class="pakb-box-icon"><i class="icon-webadres"></i></p>

    <h2>Manage</h2>

    <p class="pakb-box-desc">TEXT</p>

    <p class="pakb-view-all">TEXT</p>

</form>

With your markup set now is time for the JS:

<script type="text/javascript">
   //call a anonymous function
   $(document).ready(function(){
    //Event On click of the form
     $('#form').click(function(){

        $('#submit').trigger('click');

     })
   })

</script>

Obs: submit the form on click in his body dont makes sense to me, please explain this.

Edit:

You can learn basic JS and JQuery on www.codecademy.com