We help IT Professionals succeed at work.
Get Started

Jquery on click stopped working.

221 Views
Last Modified: 2015-04-21
I have a Coldfusion page that uses jquery on click.  It has stopped working and I have no idea why.  No changes were made to the code.  I have upgraded the site to use 1.11 and it still doesn't work.  Dev tools shows no errors.  I can set a breakpoint but it never hit's that line.  I also have 2 on change functions that also don't work.  I think I need a little help debugging this one.  There is a $(document).ready(function () { at the top of the js.   I created a standalone page based on the code below and everything works.  Where do I begin?

EDIT: Actually I am getting an error; NS_ERROR_NOT_AVAILABLE:

<tr>
				<td>
					Regular Hours:
				</td>
				<td>
					<cfinput type="text" name="regular_hours" id="regular_hours" size="11" maxlength="12" value="#decimalformat(timeSheetInfo.regular_hours)#" />
				</td>
			</tr>
			<tr>
				<td>
					Overtime Hours:
				</td>
				<td>
					<cfinput type="text" name="ot_hours" id="ot_hours" size="11" maxlength="12" value="#decimalformat(timeSheetInfo.ot_hours)#" />
				</td>
			</tr>
			<tr>
				<td>
					Total Hours Worked:
				</td>
				<td>
					<cfinput type="text" name="total_hours" id="total_hours" size="11" maxlength="12" value="#decimalformat(timeSheetInfo.Hours_Worked)#" />
				</td>
			</tr>
			<tr>
				<td>
					&nbsp;
				</td>
				<td>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					 <cfinput type="button" name="EditTimeSubmit" id="EditTimeSubmit" value="Submit Changes">
					<div id="EditTimeUpdateComplete"></div>
				</td>
			</tr>


		$('#regular_hours').on('change', function () {
			alert('step1');
			var val1 = Number(document.getElementById("regular_hours").value);
			var val2 = Number(document.getElementById("ot_hours").value);
			var val3 = val1 + val2;
			document.getElementById("total_hours").value = val3;
			});

		$('#ot_hours').on('change', function () {
			alert('step2');
			var val1 = Number(document.getElementById("regular_hours").value);
			var val2 = Number(document.getElementById("ot_hours").value);
			var val3 = val1 + val2;
			document.getElementById("total_hours").value = val3;
			});

		//$('form[name=TimeSheetDivForm2]').on('click', 'button[name=EditTimeSubmit]', function () {
		$('#EditTimeSubmit').on('click', function () {
			alert('step3');
			$.ajax({
				type: 'POST',
				url: "cfc/updates.cfc?method=UpdateTimeSheet",
				data: "&reg_profitmarginx=" + $('#reg_profitmargin').val() + "&ot_profitmarginx=" + $('#ot_profitmargin').val() + "&regular_hours=" + $('#regular_hours').val() + "&ot_hours=" + $('#ot_hours').val() + "&payroll_InvoiceNumber=" + $('#payroll_InvoiceNumber').val() + "&week_ending=" + $('#week_ending').val() + "&total_hours=" + $('#total_hours').val() + "&id=" + $('#id').val(),
				error: function(xhr, textStatus, errorThrown) {
					// show error
					alert(errorThrown);
				},
				success: function(response1, textStatus, jqXHR) {
					ColdFusion.Grid.refresh('timeSheetsGrid', true);
					ColdFusion.Grid.refresh('timeTotals', true);
					//$('#EditTimeUpdateComplete').text('Updated');
					return true;
				}
				});
			});

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2013
Awarded 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE