/    Sign up×
Community /Pin to ProfileBookmark

multiple sting for a ‘if’ statement

I am trying to make my ‘if’ statement below work with both the string “” and “http://”. I am using the || symbol for or, but it isn’t working. Any ideas?

<script language=”javascript”>
function updatefriends(){
var g=1;

while (g < 25){

if(document.getElementById(‘friendpicurl’+g).value == [COLOR=”Red”]”” || “http://”[/COLOR]){

document.getElementById(‘pic’+g).style.display = “none”;}

else{

document.getElementById(‘pic’+g).style.display = “block”;

}

g++;
}
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallJun 17.2007 — if(document.getElementById('friendpicurl'+g).value == "" || [b]document.getElementById('friendpicurl'+g).value ==[/b] "http://"){


With "http://" by itself that is always true and so your original code ends up always running the code following because the second of the items you are testing forces the result to true.
Copy linkTweet thisAlerts:
@lehulaauthorJun 17.2007 — Thankyou!!
×

Success!

Help @lehula 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...