Also habe ich diese JavaScript-Funktion, die durch jedes Benutzerkonto durchläuft und sie in einem Dropdown-Menü anzeigt. Wenn der Benutzer eine Option aus dem Dropdown-Menü auswählt, nimmt er die Iban-Nummer als Haupt-ID, die in ddlAccountFrom gespeichert ist. Gibt es eine Möglichkeit, wie ich zwei Werte speichern kann, wenn der Benutzer eine Option, wie z. B. Iban und Währung, in separate Variablen auswählt?Wie können mehrere Dropdown-Werte in einer Variablen gespeichert werden?
function getAccountFrom() {
var username = $("#hiddenUsername").val();
var url = "http://localhost:63723/api/BankAccountsApi/GetBankAccounts/?username=" + username + "&id=2";
$.getJSON(url, function (data) {
var table = "<select id=\"ddlAccountFrom\">";
table += "<option value=\"-1\">Select an Account</option>";
$.each(data, function (key, val) {
table += "<option value=\"" + val.Iban + "\">" + val.Iban + " | " + val.Currency + " | " + val.Balance + "</option>";
});
table += "</select>";
$('#divAccountFrom').html(table);
});
}
ich die ddlAccountFrom in dieser Funktion bin mit ..
function Transfer() {
var accountFrom = $("#ddlAccountFrom").val();
var accountTo = $("#txtAccountTo").val();
var amount = $("#txtAmount").val();
var url = "http://localhost:63723/api/BankAccountsApi/TransferFunds/?
ibanFrom=" + accountFrom + "&ibanTo=" + accountTo + "&amount=" + amount;
$.getJSON(url, function (data) {
alert(data);
})
.error (function() {
alert("Not enough balance! The amount entered exceed the balance found in this account. Please try again.");
})
}
Nun, Sie sollten wahrscheinlich Ihren Code zeigen, wenn der Benutzer eine Option auswählt, aber im Allgemeinen können Sie einfach die Werte mit einem Trennzeichen verketten und in den "Wert" der Option einfügen. –