 populateQuantityAvailable = (selected, element) ->
   totalAvailableQuantity = selected.data("available-quantity")
   element.text(totalAvailableQuantity)
+
+updatePlaceholder = (element, text) ->
+  element.attr("placeholder", text)
 
 addOrderRow = (orderDetails) ->
   $("#order-table tbody").append tmpl("orders-new-order-template", {})

$(document).on "change", ".order-row .category", ->
  item_element = $(@).parents(".order-row").find ".item"
  populateItems $(@).val(), item_element

$(document).on "change", ".order-row .item", ->
  quantity_element = $(@).parents(".order-row").find ".quantity"

  selected = $(@).find('option:selected')
  populateQuantity selected, quantity_element
  populateQuantityAvailable selected, quantity_available_element
  updatePlaceholder quantity_element, "Enter Quantity"
