www.webdeveloper.com
Results 1 to 2 of 2

Thread: Got stuck when I build my address book

  1. #1
    Join Date
    May 2013
    Posts
    1

    Question Got stuck when I build my address book

    I want to build an address book.

    After I added the memSearch(), the page cannot loaded in Chrome, and it said: Uncaught ReferenceError: allData is not defined.

    But when I delete memSearch(), everything is ok.

    HTML Code:
    <head>
    <script>
    function allData(){
    	for (i = 0; i  < data.length; i++) {
    		var stringInfo = data.getItem(data.key(i));
    		var memInfo = stringInfo.split(',');
    		$('#contacts').append('<div class="cards">'+'<div class="name">'+ memInfo[0] +'</div>' +'<div class="info">'+'<div class="phone">Phone:'+ memInfo[1]+'</div>'+'<div class="email">Email:'+ memInfo[2]+'</div>'+'</div>'+'</div>');
    	};
    };
    
    function memSearch(){
    	var memName = document.getElementById("mem-search-name").value;
    	var dataLength = data.length;
    	for (var i =0; i<dataLength, i++) {
    		var stringInfo = data.getItem(data.key(i));
    		var memInfo = stringInfo.split(',');
    		if (memName == data.key(i)) {
    			$('#found').append('<div class="cards">'+'<div class="name">'+ memInfo[0] +'</div>' +'<div class="info">'+'<div class="phone">Phone:'+ memInfo[1]+'</div>'+'<div class="email">Email:'+ memInfo[2]+'</div>'+'</div>'+'</div>');
    			$('#found').slideToggle();
    		};
    	};
    };
    </script>
    </head>
    <body onload="allData()">
    <div id="found"><div>
    <div id="contacts"><div>
    </body>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,377
    May be a silly question, but cannot tell from your post ...
    It appears you are trying to use JQuery. Did you remember to load the library?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles