Click here to Skip to main content
15,041,548 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i have click the select box, contact form submission should happen at same time.. which means selecting the select box, form submission should happen.

pls guide me for the solution

here is my code
     <select>
    <option class="fix">one</option>
    <option>two</option>
    <option>three</option>
   </select>


<form class="form-horizontal contact_form"  id="contactForm1"
name="myform"     action="Form.php" method="post"  enctype="multipart/form-data">
<label>Name</label>
<input type="text">
<label>Address</label>
<input type="text" placeholder="address">
<label>email id</label>
<input type="text" placeholder="email id">
<br>
<button  value="Submit" type="submit" name="submit" id="submit">submit</button>
<script>

$(document).ready(function(){
$(".fix").click(function(){
$("#submit").onclick();
alert("hello");
});
}); 


</script>

i have tried something like this
Posted
Comments
   
That is $("#submit").click(); not $("#submit").onclick();.
Sanket Saxena 28-Apr-14 8:15am
   
change your HTML dropdown code as below and try:<br><br>
 <br><br>
<select class="fix"><br><br>
<option>one</option><br><br>
<option>two</option><br><br>
<option>three</option><br><br>
</select><br>
 <br>
and js:<br>
$(document).ready(function () {<br>
$(".fix").change(function () {<br>
$('#submit').click();<br>
});<br>
});

Solution updated.

1 solution

JavaScript
<script type="text/javascript">
        $(document).ready(function () {
            $(".fix").change(function () {
                $('#submit').click();
            });
        });
    </script>


HTML
<select class="fix">
        <option>one</option>
        <option>two</option>
        <option>three</option>
    </select>
   
v2
Comments
tekthiyagu 28-Apr-14 7:59am
   
hi freind ,its not worked.pls check the output and send the code.

thanks
Sanket Saxena 28-Apr-14 8:08am
   
Check your forms and others tags are not seems to be closed properly and then check console what is the error msg?
tekthiyagu 28-Apr-14 8:27am
   
hi friend alert function is working..but form is not submitting .which means its not posting the form.php page
Sanket Saxena 28-Apr-14 8:42am
   
The code here is working fine dear...are you place this code in the content page (you are using master page it seems)
tekthiyagu 28-Apr-14 8:57am
   
thanks friend i got the solution happy coding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900