Hi,
I am new to JQuery so apologies if these questions are basic/stupid..
We are currently using raw javascript in most of our webapp and are
trying to use JQuery to do some dynamic form loading.. So here's my
scenario:
1. I have a select group (a group of select objects) where each select
object has a javascript call back when it's changed -- this javascript
is raw javascript and a parameter is passed in. Beause of time
constraints we would prefer not to change all our raw javascript to
JQuery..
2. I have created a JQuery call as follows:
$(document).ready(function(){
$("select").change(function (){
var selectedItem = $("select").attr("id");
var selectedItemValues = selectedItem.split(".");
var parentMealItem = $("#form_mealItemId").val();
var rootItem = $("#form_itemId").val();
var selectedItemDiv = "#" + selectedItemValues[0];
var loadString = "ajax-test-menu-customize.htm?selectedItem=" +
selectedItem + &parentMealItem=" + parentMealItem + "&rootItem=" +
rootItem;
$('selectedItemDiv').load(loadString);
});
});
The corresponding HTML looks like this:
<div id="parentItem" class= "selectGroup">
<select name="28007" id="28007" size="1" style="width:30;"
onChange="selectMinMaxCondiment('28386')">
<option selected="selected" value="0">0</option>
<option value="1">1</option><option value="2">2</
option>Select 1
</select> <br>
<select name="28206" id="28206" size="1" style="width:30;"
onChange="selectMinMaxCondiment('28386')"><option selected="selected"
value="0">0</option><option value="1">1</option><option value="2">2</
option>Select2
</select><br>
</div>
What I want to be able to ideally do is:
1. After my raw javascript function is done on the onChange event on a
selection, I would like it to call the JQuery function with the
parameter that was passed in to it - is this possible? If so, how?
2. I want this javascript function to be dynamic in that it should be
called for any of the select object that is changed - so if I select
the name "select1" then I want the id="28007" to be selected and if I
choose select2, then I want id="28206" to be selected.. Right now, no
matter what object I select, the "select" always triggers the first
one that was selected - is it because this variable (selectedItem)
gets created as a global variable?
Any help is appreciated.
Thanks!
Dipita