luke-sully
luke-sully

Reputation: 323

How to access HTML input element on javascript

I'm trying to retrieve the customers name by alert based on the account number that's entered into the textbox by i'm having trouble referencing the textbox (>>txtFree<<). I just not sure what i must replace it with if anyone could help please.

HTML

Account Number: <input type="text" id="txtFreeBank" name="txtFreeBank" />

JS

function checkBankAc() {
        var txtFree = parseFloat(document.getElementById('txtFreeBank').value);

        var bankdetails = Parse.Object.extend("BankDetails");
        var query = new Parse.Query(bankdetails);
        query.equalTo("AccountNum", >>txtFree<<);
        query.find({
            success: function (results) {
                alert("Successfully retrieved " + results.length + " scores.");

                for (var i = 0; i < results.length; i++) {
                    var object = results[i];
                    alert(object.id + ' - ' + object.get('CustomerName'));
                }
            },
            error: function (error) {
                alert("Error: " + error.code + " " + error.message);
            }
        });
    }

Upvotes: 1

Views: 420

Answers (1)

adolfosrs
adolfosrs

Reputation: 9389

You will be able to access the data entered switching your >>txtFree<< for the following:

document.getElementById('txtFreeBank').value

Upvotes: 1

Related Questions