I have a form which contains textboxes,”search” button. when user enter the values and click on the button I have to display the search details. and
I have to display no.of searchresults:
no.of search results i have obtained by using array.length; I want to use this value in another view page.so I put this value in the sessionStorage.setItem("getCount",len);
I am concatinating this value in the other view page like:
Search Results:" + sessionStorage.getItem('getCount') + "
I am getting the number of search results when user enters the value in the form.
but when user enter no values in the form then at the searchresults: it is displaying “null”. but i want to display “0” insted of null.
how can i do this.
There are many ways to accomplish this work. The simplest is to check if
sessionStorage.getItem('getCount')is null and if is null you can return 0.This is the code:
Search Results:" + sessionStorage.getItem('getCount') == null ? "0" : sessionStorage.getItem('getCount')