Reset HiddenField if AutoCompleteExtender returns no results
Hi i need to be able to reset a HiddenField's value if my AutoCompleteExtender returns no results (specifically, if the user searches for something that's not in the list/database). I have this JS code now:
function autoCompleteItemSelected(source, eventArgs) {
var assocHiddenField = document.getElementById(source.get_id() + '_hidden');
assocHiddenField.value = eventArgs.get_value();
}
How would I modify this to check if the 开发者_Python百科list is null? Currently it seems to just leave the value as it was previously.
Thanks
I tried to set null and an empty array to the value of the hiddenInput and both work fine. Could you alert the value of 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" />
精彩评论