I want to add product record under a product category. But if expected category not found on the select option I don't want cancel from this step I just want to add a category from this step. If I add the category then it will load select option without page refreshing.
Here I have to select option field
After saving category it will load on the select option field
First use a different php page to call only options in select.
Then,
<script>
$("#id_of_submit_button").click(function(){
var category = $('#id_of_input').val();
$.ajax({
type: 'POST',
url: 'page_to_insert_category.php',
data: {category:category},
success:function(data){
//call the function which you used to get the options again
}
});
</script>
You will get the value of category in php page as
$_POST['category']
1.on click of submit button call an ajax 2. on same controller after save write logic for updated records in desc order and return in response updated array. 3. in success of ajax write logic for select last id record. ex. ($('#your_id [value=3]').attr('selected', 'true');) 4. trigger update on that select dropdown variable. ex. $('#mySelect').val('ab').trigger("updated");