Javascript by itself cannot access a database, but it can power an AJAX call, pass some values to the script being called (PHP, ASP, etc) and that script can then save that data in the database.
Consider the code below, a typical DOM event driven ajax call, made easy by jQuery:
<script type="text/javascript">
function checkAppointmentDateAvailability(){
$.ajax({
type: "POST",
url: "includes/ajax-check-appointment-date.php",
data: "appointment_date=" + document.getElementById("appointment_date").value,
success: function(html){
$("#appointment_availability_div").html(html);
}
});
}
</script>
You can either do the calculation in JS then send the total amount to the script to be saved, or send the raw values to the script and it will do the calculations for you and save.
Hi all of you I have this application am making and its suppesd to make claims of refund, part of the script is here
But I cannot save this data into all the database
/*****************************************************************************************************************************/
function getValues(val){
var numVal1=parseInt(document.getElementById("milleage_start").value);
var numVal2=parseInt(document.getElementById("milleage_finish").value);
var numVal3=parseInt(document.getElementById("amount").value);
var rate = 35.00;
var totalValue = numVal1 - numVal2;
var totalAmount = totalValue * rate;
document.getElementById("milleage").value = totalValue;
document.getElementById("amount").value = totalAmount;
}
/*****************************************************************************************************************************/
<td><div align="right">Finish</div></td>
<td><input type="text" name="textfield9" id="milleage_start" class="required" onkeyup="getValues(1)"/></td>
</tr>
<tr>
<td><div align="right">Start </div></td>
<td><input type="text" name="textfield10" id="milleage_finish" class="required" onkeyup="getValues(2)" /></td>
</tr>
<tr>
<td td bgcolor="#E0E0E0"><div align="left"><strong>Total Milleage (KM) </strong></div></td>
<td td bgcolor="#E0E0E0"><strong>
<input type="text" name="milleage" id="milleage" onkeyup="getValues(3)" class="required" values=""/>
<input type="hidden" name="milleage" id="milleage" />
</strong></td>
</tr>
<tr>
<td><div align="right">Amount in KShs </div></td>
<td><strong>
<input type="text" name="amount" id="amount" class="required" values="" />
<input type="hidden" name="amount" id="amount" />
(Rate
@ Kshs 35)</strong></td>
Any idea and help will be most appreceated
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
Other lists
-------------
Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general