I have the following code . After data is entered into the bold highligted field, the onchange function is to be called. It does not however do that and i have tired all i know assuming the url function works. please help me.
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
var url = "calCharges.php?param="; // The server-side script
var url2 = "getExchrate.php?param=";
function calCharges() {
var transamt = document.moneytrans.transamt.value;
if (transamt == "")
return;
http.open("GET", url + escape(transamt), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getExchrate() {
var transcrncy = document.moneytrans.transcrncy.value;
var paycrncy = document.moneytrans.paycrncy.value;
var trancurcode = transcrncy+paycrncy;
http.open("GET", url2 + escape(trancurcode), true);
http.onreadystatechange = handleHttpResponse2;
http.send(null);
}
function handleHttpResponse2() {
if (http.readyState == 4) {
// Split the comma delimited response into an array
results2 = http.responseText.split(",");
document.moneytrans.exchrate.value = results2[1];
}
}
function handleHttpResponse() {
if (http.readyState == 4) {
// Split the comma delimited response into an array
var results = http.responseText.split(",");
getExchrate();
document.moneytrans.chrgesappd.value = results[0];
document.moneytrans.paycrncyamt.value = (document.moneytrans.exchrate.value) * (document.moneytrans.transamt.value);
document.moneytrans.tottransaccrd.value = (document.moneytrans.paycrncyamt.value) * (document.moneytrans.chrgesappd.value);
}
}
function getHTTPObject() {
var xmlhttp=null
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e)
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}
}
if (xmlhttp==null)
{
xmlhttp=new XMLHttpRequest()
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
</script>
<link rel="stylesheet" type="text/css" media="" href="main.css">
<title></title>
</head>
<body>
<?php
require_once('db_fns.php');
$username = $_SESSION['valid_user'];
$conn = db_connect();
if (!$conn)
return 'Could not connect to database1 server - please try later.';
mysql_select_db('globalexpat');
$query = "select gad1 from securitable where username ='$username'";
$result = mysql_query($query);
//$num_results = mysql_num_rows($result);
$row1 = mysql_fetch_array($result);
$gad1 = stripslashes($row1['gad1']);
$query = "select firstname, surname, cntyrsdnc from perdattable where gad1 = '$gad1'";
$result2 = mysql_query($query);
$row2 = mysql_fetch_array($result2);
$firstname = stripslashes($row2['firstname']);
$surname = stripslashes($row2['surname']);
$cntyrsdnc = stripslashes($row2['cntyrsdnc']);
$_SESSION['countres'] = $cntyrsdnc;
?>
<div id="wrapper">
<div id="branding"><h2>GLOBAL EXPATRIATE SERVICES Money Transfer</h2></div>
<div id="content">
<form name="moneytrans" action="store_moneytrans.php" method="POST">
<fieldset><legend>Your Personal Details</legend>
<?php
echo '<p><label for="gad1">Account No: </label></p>'.$gad1;
echo '<br />';
echo '<p><label for="firstname">FirstName: </label></p>'.$firstname;
echo '<br />';
echo '<p><label for="surname">Surname: </label></p>'.$surname;
echo '<br />';
echo '<p><label for="username">Username: </label></p>'.$username;
echo '<br />';
echo '<p><label for="cntyrsdnc">Country of Residence: </label></p>'.$cntyrsdnc;
?>
</fieldset>
<fieldset><legend>Customer Deposit Apportionment</legend>
<p><label for="transcrncy">Transfer Currency</label><input name="transcrncy" id="transcrncy" type="text"></p>
<p><label for="paycrncy">Payment Currency:</label><input name="paycrncy" id="paycrncy" type="text"></p>
<p><label for="transamt">Transfer Amount:</label><input name="transamt" id="transamt" type="text" onchange="calCharges()"></p>
<p><label for="payrecdat">Payment Recievable Date:</label><input name="payrecdat" id="payrecdat" type="text"></p>
<p><label for="projacc">Project Account:</label><input name="projacc" id="projacc" type="text"></p>
<p><label for="famiacc">Family Account:</label><input name="famiacc" id="famiacc" type="text"></p>
<p><label for="depoacc">Banking in Ghana:</label><input name="depoacc" id="depoacc" type="text"></p>
</fieldset>
<fieldset><legend>Payment Card Details</legend>
<p><label for="cardnumb">Card Number:</label><input name="cardnumb" id="cardnumb" type="text"></p>
<p><label for="cardtype">Card Type:</label><input name="cardtype" id="cardtype" type="text"></p>
<p><label for="validdat">Valid From:</label><input name="validdat" id="validdat" type="text"></p>
<p><label for="enddat">End Date:</label><input name="enddat" id="enddat" type="text"></p>
<p><label for="issunumb">Issue Number: (if applicable)</label><input name="issunumb" id="issunumb" type="text"></p>
<p><label for="cardvercod">Card Verification Code:</label><input name="cardvercod" id="cardvercod" type="text"></p>
<p><label for="addrcard">Card Address:</label><input name="addrcard" id="addrcard" type="text"></p>
<p><label for="postcod">Zip/Post Code:</label><input name="postcod" id="postcod" type="text"></p>
<p><label for="cntrcard">Country:</label><input name="cntrcard" id="cntrcard" type="text"></p>
<p><label for="fremnytrans">Register for free money transfer (Y/N):</label> <input name="fremnytrans" id="fremnytrans" type="text"></p>
</fieldset>
<fieldset><legend>Reciepient Details</legend>
<p><label for="namrecpt">Reciepient Name:</label><input name="namrecpt" id="namrecpt" type="text"></p>
<p><label for="addrline1">Address Line 1:</label><input name="addrline1" id="addrline1" type="text"></p>
<p><label for="addrline2">Address Line 2:</label><input name="addrline2" id="addrline2" type="text"></p>
<p><label for="addrtown">Town:</label><input name="addrtown" id="addrtown" type="text"></p>
<p><label for="pstcode">Zip/Post Code:</label><input name="pstcode" id="pstcode" type="text"></p>
<p><label for="cntraddr">Country:</label><input name="cntraddr" id=cntraddr" type="text"></p>
<p><label for="phonenumb">Phone Number:</label><input name="phonenumb" id="phonenumb" type="text"></p>
<p><label for="emailaddr">Recipient Email:</label><input name="emailaddr" id="emailaddr" type="text"></p>
<p><label for="askrecpt">Security Question:</label><input name="askrecpt" id="askrecpt" type="text"></p>
<p><label for="ansrecpt">Answer:</label><input name="ansrecpt" id="ansrecpt" type="text"></p>
</fieldset>
<fieldset><legend>Special Details</legend>
<p><label for="exchrate">Exchange Rate :</label><input name="exchrate" id="exchrate" type="text"></p>
<p><label for="paycrncyamt">Payment Currency Amount :</label><input name="paycrncyamt" id="paycrncyamt" type="text"></p>
<p><label for="chrgesappd">Charges Applied:</label><input name="chrgesappd" id="chrgesappd" type="text"></p>
<p><label for="tottransaccrd">Total Transfer From Card:</label><input name="tottransaccrd" id="tottransaccrd" type="text"></p>
<br />
<input type="submit" value="Confirm">
<input type="reset" value="Reset">
</fieldset>
</form>
We will send confirmation of Transaction to Your Email Address or Mobile Number
</div>
<div id="mainNav">
<ul>
<li>
<a href="about.php">About US</a></li>
<li>
</ul>
</div>
<div id="footer">footer</div>
</div>
</body>
</html>