Skip to content

Instantly share code, notes, and snippets.

@avostryakov
Created April 2, 2010 18:02
Show Gist options
  • Save avostryakov/353467 to your computer and use it in GitHub Desktop.
Save avostryakov/353467 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$("select[id*='id_products-']").css("width", "145px");
function getSizeSelectField()
{
product_type = $("#id_product_type").val();
fields = $("select[id*='-size']").serializeArray();
$("select[id*='-size']").load('{% url shop.views.getSelectField %}' + '?type=size&object_id=' + product_type,
function() {
$.each(fields, function(i, field) {
name = "#id_" + field.name
$(name).val(field.value);
if ($(name).val() == null)
{
$(name).val("")
}
});
})
}
$("#id_product_type").change(getSizeSelectField);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment