Skip to content

Instantly share code, notes, and snippets.

@axilaris
Created March 16, 2014 23:27
Show Gist options
  • Select an option

  • Save axilaris/9591377 to your computer and use it in GitHub Desktop.

Select an option

Save axilaris/9591377 to your computer and use it in GitHub Desktop.
$(document).ready ->
state_cache = {}
$('#invoice_product_code_invoice_product_code').change ->
invoice_product_code = $(this).val()
console.log invoice_product_code
switch invoice_product_code
when 'INVPRODA'
$('#product_name').val('Product A');
when 'INVPRODB'
$('#product_name').val('Product B');
when 'Add New'
$("#invoice_product_code_invoice_product_code").val('INVPRODA');
$('#windowCreateInvoiceProductDialog').modal("show");
else
$('#product_name').val('Something') ;
@axilaris
Copy link
Copy Markdown
Author

$(document).ready(function() {
var state_cache;
state_cache = {};
return $('#invoice_product_code_invoice_product_code').change(function() {
var invoice_product_code;
invoice_product_code = $(this).val();
console.log(invoice_product_code);
switch (invoice_product_code) {
case 'INVPRODA':
return $('#product_name').val('Product A');
case 'INVPRODB':
return $('#product_name').val('Product B');
case 'Add New':
$("#invoice_product_code_invoice_product_code").val('INVPRODA');
return $('#windowCreateInvoiceProductDialog').modal("show");
default:
return $('#product_name').val('Something');
}
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment