Monday, November 12, 2012

php – How to submit a form with dropdown selected value only?

I want to submit a form which has just one dropdown with language values and i want to submit form and get access to that value so that i can localize some text on the page.


This is the code i am using but not able to access the post values


html form:



<form action=\'\' method=\'post\'>
<select id=\"lang\">
<option value=\"english\">Eng</option>
<option value=\"arabic\">Arabic</option>
</select>
</form>


jQuery to submit the form:



<script type=\"text/javascript\">
jQuery(function($){
var lang = $(\"#lang\").val();
var Home = \'الرئيسية\';

$(\"#lang\").change(function(){
cntr = $(\"#lang option:selected\").val();

if(lang==\"arabic\"){
$(\".menu ul li a:eq(0)\").text(Home);
}
$(\'form\').submit();
});
});


</script>






Rating: 5 out of 5 based on 3 ratings



The post php – How to submit a form with dropdown selected value only? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/php-how-to-submit-a-form-with-dropdown-selected-value-only.html

No comments:

Post a Comment