2 탭이있는 jQuery 탭 요소가 있습니다. 각 탭에는 자체 작업 페이지가있는 양식이 있습니다.jQuery 숨겨진 양식 필드에서 ColdFusion 쿼리
페이지 새로 고침을 방지하고 데이터를 내 작업 페이지에 게시하는 JavaScript 코드가 있습니다.
내 양식의 두 번째 탭에는 CFLoop에 의해 만들어진 여러 고유 한 양식 요소가 있습니다. 데이터베이스에서 특정 레코드를 삭제할 때이 방법을 사용합니다. 그러나 양식을 제출하면 내 작업 페이지의 쿼리에서 오류가 발생합니다.
500 (. 오류 실행 데이터베이스 쿼리)
: 나는 방화범에 오류가 있지만 화면에 (사람이 더 자세히는 ColdFusion 오류 코드를 볼 수있는 방법을 알고있는 경우, 즉 도움이 될 것입니다)하지를 볼 수 있습니다레코드 ID를 숨겨진 양식 필드 형태로 작업 페이지의 쿼리에 전달합니다. jQuery를 사용하여 다른 방식으로이 작업을 수행해야합니까? 도와 주셔서 감사합니다.
양식 코드 :
<cfloop query="get_trips">
<tr class="vehicle-log-table">
<td class="vehicle-log-table">#DateFormat(get_trips._date, "mm-dd-yyyy")#</td>
<td class="vehicle-log-table"><div align="center">#get_trips.total_mileage#</div></td>
<td class="vehicle-log-table"><div align="center">#get_trips.expenses#</div></td>
<td class="vehicle-log-table">
<div align="right">
<form class="deleteMileageForm" id="deletemileage#get_trips.currentRow#" method="post">
<input class="vehicle-log-form" type="submit" id="submit2" name="submi2" value="Delete">
<input type="hidden" id="hidden" name="hidden" value="#get_trips.id#">
</form>
</div><br />
<span class="errorTab2" style="display:none"> <font color="##FF0000"> <strong>Trip Not Deleted</strong></font></span>
<span class="successTab2" style="display:none">
<font color="##00FF00">
<strong>Trip Deleted Successfully</strong>
</font>
</span>
</td>
</tr>
</cfloop>
jQuery를 코드 :
<script>
$(document).ready(function() {
//Submit form to add record.
$('#addmileage').submit(function (e) {
e.preventDefault();
$.ajax({
data: $('#addmileage').serialize(),
type:'POST',
url:'actionpages/add_trip.cfm?ticketid=<cfoutput>#url.ticketid#</cfoutput>',
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}
});
});
$('.deleteMileageForm').submit(function (e) {
e.preventDefault();
$.ajax({
data: $('.deleteMileageForm').serialize(),
type:'POST',
url:'actionpages/delete_trip.cfm',
success: function(){
$('.successTab2').fadeIn(200).show();
$('.errorTab2').fadeOut(200).hide();
}
});
});
});
</script>
ColdFusion에서 쿼리
<!---Delete Trip --->
<cfoutput>
<cfquery name="deleteTrips" datasource="#datasource#">
delete from vehicle_log
where ID = #form.hidden#
</cfquery>
</cfoutput>
사람이 도와 드릴까요? 매우 감사.
고유 한 ID를 만들어야합니다. –
cfform을 사용할 이유가없는 것으로 보입니다. 정규 양식은 잘 작동합니다. –