从文本框访问数据

时间:2011-05-22 17:20:35

标签: javascript

function testTask06()
{
    var cipherText = document.getElementById('cipherTextBox').value;
    var indexCharacter = document.getElementById('indexCharacterTextBox').value;
    document.getElementById('plainTextBox').value = (decryptMessage(cipherText, indexCharacter, plainArray, cipherArray));
}

我想从文本框中获取名为'cipherTextBox'和'indexCharacterTextBox'的值,然后在我的函数decryptMessage中使用这些值,然后在textbox'plainTextBox'中显示结果。它不起作用,但我想知道是否因为我的函数decryptMessage是错误的。

1 个答案:

答案 0 :(得分:2)

This basic example有效

function foo() {
    var cipherText = document.getElementById('cipherTextBox').value;
    var indexCharacter = document.getElementById('indexCharacterTextBox').value;
    document.getElementById('plainTextBox').value = 
        decryptMessage(cipherText, indexCharacter, [], []);
}

function decryptMessage(a, b) {
    // dummy function
    return a + b;
}

document.getElementById("button").addEventListener("click", foo, false);

您的decryptMessage功能可能有问题。我们需要看到这一点。