Skip to content

Autofilling event data for testing

kylehardgrave edited this page Feb 18, 2013 · 2 revisions

If you find yourself having to test the CFA submitting process, you'll probably want to not fill out a whole applications each time. Use this code to help you:

function populate() {
  $("#questionname").val("Socrates Speaks");
  $("#questiondate").val("03/17/2013");
  $("#questiontime").val("12:00:00");
  $("#questionlocation").val("Philo Halls");
  $("#questioncontactemail").val("kyleh@sas.upenn.edu");
  $("#questioncontactphone").val("3013054038");
  $("#questionanticipatedattendance").val("40");
  $("#questionadmissionfee").val("0");
  $("#questionadvisoremail").val("kyleh@seas.upenn.edu");
  $("#questionadvisorphone").val("3013054038");
  $("#questionorganizations").val("The Philomathean Society, SCUE");
  $(".commonfreeresponsequestion").val("My thoughtful response to this question");

  var revTable = $($('table.table')[0]);
  var expTable = $($('table.table')[1]);

  // Add some line items under revenue                                          
  revTable.find("tr input[name='item_name']")[0].value = "Tix";
  revTable.find("tr input[name='item_quantity']")[0].value = "40";
  revTable.find("tr input[name='item_price_per_unit']")[0].value = "3";

  // Add some line items under expenses                                         
  expTable.find('.btn.add.add-item').click().click();
  expTable.find("tr input[name='item_name']")[0].value = "Soda";
  expTable.find("tr input[name='item_name']")[1].value = "Juice";
  expTable.find("tr input[name='item_name']")[2].value = "Milkshakes";

  expTable.find("tr input[name='item_quantity']")[0].value = "3";
  expTable.find("tr input[name='item_quantity']")[1].value = "40";
  expTable.find("tr input[name='item_quantity']")[2].value = "5";

  expTable.find("tr input[name='item_price_per_unit']")[0].value = "10";
  expTable.find("tr input[name='item_price_per_unit']")[1].value = "5";
  expTable.find("tr input[name='item_price_per_unit']")[2].value = "12";

  expTable.find("tr input[name='item_funding_already_received']")[0].value = "0";
  expTable.find("tr input[name='item_funding_already_received']")[1].value = "15";
  expTable.find("tr input[name='item_funding_already_received']")[2].value = "0";

  // Do the updates                                                             
  calculateAmount();
  updateTotal();
}
Clone this wiki locally