2

こんにちは、AutoCompleteExtenderが結果を返さない場合(特に、ユーザーがリスト/データベースにないものを検索した場合)、HiddenFieldの値をリセットできる必要があります。私は今このJSコードを持っています:

function autoCompleteItemSelected(source, eventArgs) {
    var assocHiddenField = document.getElementById(source.get_id() + '_hidden');
    assocHiddenField.value = eventArgs.get_value();
}

これを変更して、リストがnullかどうかを確認するにはどうすればよいですか?現在は、以前の値のままにしているようです。

ありがとう

4

1 に答える 1

0

nullと空の配列をhiddenInputの値に設定しようとしましたが、どちらも正常に機能します。assocHiddenField.valueの値を警告できますか?

<button onclick="resetHiddenInputValue();"> Reset hidden input! </button>
    <script type="text/javascript">
        function resetHiddenInputValue() {
            var hiddenInput = document.getElementById("hiddenInputId");

            alert('The value of the hidden input before the action:' + hiddenInput.value);
            var searchResult = null;
            // var searchResult = new Array(); 
            hiddenInput.value = searchResult;
            alert('The value of the hidden input after the action:' + hiddenInput.value);
        }
    </script>
<input type="hidden" value="hiddenvalue1" id="hiddenInputId" />
于 2011-01-04T12:21:32.333 に答える