Saturday, September 28, 2013

JQUERY CODE TO PERFORM FUNCTION ON SELECTING SELECT BOX OPTIONS

Hiiii, Sometimes it is necessary to get an ID of the selected select box options and then perform some function on that selected ID. So, here is the code to perform some work on the options selected for some select box with the help of JQuery. It  means that you don’t have to submit that form but function performs on just select.
JQUERY FUNCTION ON SELECTING SELECT BOX OPTIONS

So here is the simple and short JQuery code to do so:

jQuery(document).ready(function(){
jQuery( “#Attr” ).change(function () {             //#Attr is the id of the select box
var id = jQuery(this).val();
//alert(id);
var request_type=”get_desc”;
jQuery.ajax({
type: “POST”,
url: “abcd.php”,              //abcd.php is the file name to which data is to be sent
data: {req_type:request_type,attr_id:id}
}).done(function( msg ) {
//alert(msg);
jQuery(“#attribute_description”).val(msg);
});
});
})
The above code sends the data (value of option selected, etc) on “abcd.php” on the change of select box (with ID : Attr) options and receive a data back in “msg” variable , whose value is then inserted into a text area with ID : attribute_description.

Hope you like this post……..Please Comment…………!!!!!!!!!

Originally posted at Mycodestock.


Tags: ,

0 Responses to “JQUERY CODE TO PERFORM FUNCTION ON SELECTING SELECT BOX OPTIONS”

Post a Comment

© 2013 MyCodeStock. All rights reserved.
Designed by SpicyTricks