Hello guys.

i am trying to create a php + ajax form that enables the user to make a transfer from their account to another.

is this correct what i am doing so far?

`for the ajax file
function sendpayment(){
    var payment = _("SendPayment").value;
    var touser =_("ToUser".value;
    if (payment == "") { 
        _("status").innerHTML = "Type Amount";} else {
            _("status").innerHTML = "Processing.."; }
            {
            var ajax = ajaxObj("POST", "payment.php"); 
            var response = ajax.responseText;
                if(response == "success"){
                    _("paymentform").innerHTML = '<h3>Your Payment was Sucessful</h3>';}
                    else {
                    _("status").innerHTML = 'Your payment has not been sucessful';}
}
}
ajax.send("payment="+payment+"&touser="+toUser+");`



// FOR THE HTML FILE
<form name="sendpayment" method="post" action="payment.php">
  <label for="SendPayment">Payment</label>
  <input type="text" name="SendPayment" id="SendPayment">
  <label for="ToUser">To User:</label>
  <input type="text" name="ToUser" id="ToUser">
  <input name="Send" type="button" id="paymentdone()" value="Send Payment">

</form>

I am a total newbie yet when it comes to php, i would love to hear your feedback and pointing me in the right direction.

Kind greetings. :D

Hi snitcher,

Have you tried to run your code?

Ok, let's talk about javascript portion of your code:

    // javascript
    function sendpayment(){
        var payment = _("SendPayment").value;
        var touser =_("ToUser".value;
        if (payment == "") { 
            _("status").innerHTML = "Type Amount";} else {
                _("status").innerHTML = "Processing.."; }
                {
                var ajax = ajaxObj("POST", "payment.php"); 
                var response = ajax.responseText;
                    if(response == "success"){
                        _("paymentform").innerHTML = '<h3>Your Payment was Sucessful</h3>';}
                        else {
                        _("status").innerHTML = 'Your payment has not been sucessful';}
    }
    }
    ajax.send("payment="+payment+"&touser="+toUser+");

First:
Look at line 4, you forgot to close the parentheses.
Now look at line 17, you forgot to close the qoute.

Second:
Who told you that the use of the syntax _("element_id") is valid?
In javascript you would use document.getElementById("element_id") to get an element.

Third:
Don't name any of your functions a name you've given to an element.

Now your syntax is correct, you should look into the logic behind your code.. because it doesn't do what you intend to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.