Reputation: 2422
Well i'm submitting form through onChange
of select
<form name="selForm" id="selForm" type="POST>
<select name="sel_status" id="sel_status">
<option value="one">one</option>
<option value="two">two</option>
</select>
</form>
My jQuery Code
$('#sel_status').change(function(){
$('#selForm').submit();
});
And then i'm echoinging the value submitted in php
echo $_POST['sel_status'];
My network tab in Chrome showing 302 status
So how to submit the form through onChange of select and receive those values in php?
Upvotes: 2
Views: 427
Reputation: 2802
Add form action="yourphpfile.php"
and change method="POST"
.
Try:
echo $_POST['sel_status'];
Upvotes: 0
Reputation: 2729
<form name="selForm" id="selForm" type="POST">
The action
is missing and it's method
, not type
Upvotes: 1
Reputation: 405
You've got an error in your HTML code.
First, there is a " missing (after POST) and this attribute is called method, not type. So the correct code should be:
<form name="selForm" id="selForm" method="post">
<select name="sel_status" id="sel_status">
<option value="one">one</option>
<option value="two">two</option>
</select>
</form>
If your PHP code is in an other file, you also have to set the action="yourfile.php"
attribute
Upvotes: 1
Reputation: 2177
Use $_POST['sel_status'];
You cannot use echo $_POST['selForm']; "selForm" is name of the form.
Upvotes: 0