/    Sign up×
Community /Pin to ProfileBookmark

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.

[code=html]
<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&#65306;’+ memInfo[1]+'</div>’+'<div class=”email”>Email&#65306;’+ memInfo[2]+'</div>’+'</div>’+'</div>’);
};
};

function memSearch(){
var memName = document.getElementById(“&#65532;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&#65306;’+ memInfo[1]+'</div>’+'<div class=”email”>Email&#65306;’+ memInfo[2]+'</div>’+'</div>’+'</div>’);
$(‘#found’).slideToggle();
};
};
};
</script>
</head>
<body onload=”allData()”>
<div id=”found”><div>
<div id=”contacts”><div>
</body>[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERMay 15.2013 — 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?
×

Success!

Help @rockygioso spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...