I have a select element that has a change event attached so that, when the user selects a new option, that text is placed into a corresponding input element. That's working fine:
$("select[name='" + dropdown_name + "']").live("change", function()
{
text = $("select[name='" + dropdown_name + "'] option:selected").text();
$("#" + inputfield).val(text);
});
However, when another select is changed, that select field's html is changed according to an AJAX request. When this happens, the selected value from the select element pre-HTML change is placed into the input field.
$.get("file.php", {x: x, y: y}, function(text)
{
$("select[name='dropdown_name']").html(text).removeAttr("disabled");
if (!$("select[name='dropdown_name'] option.selected").length)
{
$("select[name='dropdown_name'] option[value='1']").attr("selected", "selected");
}
$("#_inputfield").removeAttr("disabled");
});
How do I prevent that particular function from occurring only when the HTML is changed?