I am trying to bring my programming skills together ... but I have hit a
road block.

I am writing my own ledger (accounting) software.

I am needing help to pass 2 variables generated by Ajax through my form
to be saved in a mySQL table.

A sample of what ledger_select_account.js outputs is as follows --- the
PHP script it accesses queries a table and then echo's this to the
screen.

<SELECT name="account_reference">
<OPTION value ="1">PayPal (REF: 1)</OPTION>
<OPTION value ="3">Receiver General (REF: 3)</OPTION>
<OPTION value ="2">TD Canada Trust (REF: 2)</OPTION>
</SELECT>

The source code for ledger_select_account.js is:

var xmlHttp

function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ledger_account_details.php";
url=url+"?account_source="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged () {
    if (xmlHttp.readyState == 4) {
        document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
    } else {
        //alert(xmlHttp.readyState)
    }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
} 


A sample of what ledger_select_gifi.js outputs is as follows --- the PHP
script it accesses queries a table and then echo's this to the screen.

<SELECT NAME="gifi_reference">
<OPTION VALUE="9">Bank Charges (8715: Bank Charges)</OPTION>
<OPTION VALUE="10">Benevolent Fund (9270: Other Expenses)</OPTION>
<OPTION VALUE="13">Computer Equipment  / Software (1774: Computer
Equipment / Software)</OPTION>
<OPTION VALUE="4">Office Expenses (8811: Office stationery and
supplies)</OPTION>
<OPTION VALUE="12">Our Advertising Campaign Expenses (8521:
Advertising)</OPTION>
<OPTION VALUE="8">Photocopying (8810: Photocopying)</OPTION>
<OPTION VALUE="7">Postage (9275: Delivery, Freight and Express)</OPTION>
<OPTION VALUE="5">Telephone Expenses (9225: Telephone and
Communications)</OPTION>
<OPTION VALUE="6">Web Site Hosting (9152: Internet)</OPTION>
</SELECT>

The source code for ledger_select_gifi.js is:

var xmlHttp2

function showGIFI(str)
{ 
xmlHttp2=GetXmlHttpObject();
if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ledger_gifi_details.php";
url=url+"?transaction_type="+str;
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);
}

function stateChanged2 () {
    if (xmlHttp2.readyState == 4) {
        document.getElementById("txtGIFI").innerHTML=xmlHttp2.responseText;
    } else {
        //alert(xmlHttp.readyState)
    }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
} 



The form which submits the ledger entry is this:



<head>
<script src="ledger_select_account.js"></script>
<script src="ledger_select_gifi.js"></script>
</head>

<center>
<table>
<tr><td width=800>
<font face="times new roman">
<center><u>New Ledger Entry</u></center><p>


<center>
<table>

<form method=POST action="index.php?request=receive_ledger_entry_record">

<tr><td align="right"><font face="times new roman">Name Record Source:</td>
<td>
<SELECT NAME="account_source" onchange="showCustomer(this.value)">
<OPTION VALUE="0">MAKE YOUR SELECTION</OPTION>
<OPTION VALUE="1">Member Services Account</OPTION>
<OPTION VALUE="2">Ledger Account</OPTION>
<OPTION VALUE="3">Supplier</OPTION>
<OPTION VALUE="4">Advertiser Account</OPTION>
</SELECT>
</td></tr>

<tr><td align="right"><font face="times new roman">Account Reference:</td>
<td>
<div id="txtHint"><b>Account holder information will be listed here.</b></div>
</td></tr>


<tr><td align="right"><font face="times new roman">Transaction Type:</td>
<td>
<SELECT NAME="transaction_type" onchange="showGIFI(this.value)">
<OPTION VALUE="0">MAKE YOUR SELECTION</OPTION>
<OPTION VALUE="1">Donation</OPTION>
<OPTION VALUE="2">Expense</OPTION>
<OPTION VALUE="3">Income</OPTION>
<OPTION VALUE="4">PayPal Funds Transfer</OPTION>
<OPTION VALUE="5">Payroll</OPTION>
</SELECT>
</td></tr>

<tr><td align="right"><font face="times new roman">GIFI Reference:</td>
<td>
<div id="txtGIFI"><b>GIFI information will be listed here.</b></div>
</td></tr>

<tr><td align="right"><font face="times new roman">Transaction Date 
(YYYY-MM-DD):</td>
<td>
<input type=text name="transaction_date" size=40 maxlength=10>
</td></tr>

<tr><td></td><td>

<table>

<tr><td align="right"><font face="times new roman">Foreign Currency 
Received:</td>
<td>
<font face="times new roman">$ <input type=text 
name="foreign_currency_dollar_value" size=20 maxlength=12>
</td></tr>

<tr><td align="right"><font face="times new roman">Foreign Currency 
Identifier:</td>
<td>
<SELECT NAME="foreign_currency_identifier">
<OPTION VALUE="0"></OPTION>
<OPTION VALUE="1">U.S. Funds</OPTION>
</SELECT>
</td></tr>

<tr><td align="right"><font face="times new roman">Foreign Currency Exchange 
Rate:</td>
<td>
<font face="times new roman">$ <input type=text 
name="foreign_currency_exchange_rate" size=20 maxlength=14>
</td></tr>

</table>

</td></tr>

<tr><td align="right"><font face="times new roman">Dollar Value:</td>
<td>
<font face="times new roman">$ <input type=text name="dollar_value" size=20 
maxlength=11>
</td></tr>

<tr><td align="right"><font face="times new roman">Bank Account Reference:</td>
<td>
<SELECT NAME="bank_account_reference">
<OPTION VALUE="2">PayPal</OPTION>
<OPTION VALUE="1">TD Canada Trust</OPTION>
</SELECT>
</td></tr>

<tr><td align="right"><font face="times new roman">Cheque Reference:</td>
<td>
<input type=text name="cheque_reference" size=10 maxlength=5>
</td></tr>

<tr><td align="right"><font face="times new roman">Bank Account Balance:</td>
<td>
<font face="times new roman">$ <input type=text name="bank_account_balance" 
size=20 maxlength=8>
</td></tr>

<tr><td align="right"><font face="times new roman">Notepad:</td>
<td>
<textarea COLS=40 ROWS=5 name="notepad"></textarea>
</td></tr>

<tr><td></td>
<td>
<input type="submit" name="submit" value="Submit Ledger Entry">
</form>
</td></tr>
</table>
</center><p>



The form processes and goes into this INSERT INTO statement:

@mysql_select_db($database) or die( "Unable to select database");
mysql_query("INSERT INTO `ledger_entry`
(`reference` ,`account_source` ,`account_reference` ,`transaction_type` 
,`gifi_reference` ,`transaction_date` ,`foreign_currency_dollar_value` 
,`foreign_currency_identifier` ,`foreign_currency_exchange_rate` 
,`dollar_value` ,`bank_account_reference` ,`cheque_reference` 
,`bank_account_balance` ,`created_by` ,`notepad` ,`entry_date`)VALUES (NULL , 
'$account_source', '$account_reference', '$transaction_type', 
'$gifi_reference', '$transaction_date', '$foreign_currency_dollar_value', 
'$foreign_currency_identifier', '$foreign_currency_exchange_rate', 
'$dollar_value', '$bank_account_reference', '$cheque_reference', 
'$bank_account_balance', '$record', '$notepad', '$entry_date');");
$created_ledger_record_reference = mysql_insert_id();
mysql_close();

All the variables, but the two ajax ones ( $account_reference &
$gifi_reference ) make it into the table.  

I initially just had 1 ajax set up ( ledger_select_account.js ) .  When
there was just the one the value of $account_reference was inserted into
the ledger_entry table.  At that point I was still displaying all of the
possible GIFI codes which could be selected.  

I am now only wanting to display the GIFI codes which are relevant.  

I am able to make the selects ... so I know the ajax works; but some
where between my form and when it is submitted the numerical values
aren't being passed on.  

I don't know where to post this for help; would you help me get this
sorted out?  Please make sure all responses are e-mailed to me directly
[EMAIL PROTECTED] .  

Thanks for helping get me through this,

Ron

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to