Function Looping Problem ?

Recommended Posts

Tia ;

I need more eyes :

Can't figure out my error in

What am I doing wrong , Thanks for your Help...

```<!DOCTYPE html>
<html>
<style>
span.buttons {
display: inline; /* the default for span */
}
p {
border: 1px solid blue;
}
</style>
<body>
<div style="text-align: center">
<input type="text" placeholder="Enter URL" id="myInput" value="http://www.google.com">
<button type="button" onclick="getInputValue()" >Get URL</button>

</div>
<p>
<span class="buttons"><button onclick="WholeSite(0)">duckduckgo.com/</button></span>
<span class="buttons"><button onclick="SpecificSite(0)">http://vmars.us/SafeBrowser/SafeBrowserHome.html</button></span>
</p>
<p>
<span class="buttons"><button onclick="WholeSite(1)">pbskids.org/</button></span>
</p>
<p>
<span class="buttons"><button onclick="WholeSite(2)">.sesamestreet.org/</button></span>
</p>

<script>
var NavigateTo = "" ;
var SafeSite = false ;
var arrayPos = 0 ;

SafeSite = false ;
for (var i = 0; i < wholeSiteLinksArray.length; i++) {
SafeSite = true ;
}else {
SafeSite = false ;
}
}
}

SafeSite = false ;
for (var i = 0; i < specificSiteLinksArray.length; i++) {
SafeSite = true ;
}else {
SafeSite = false ;
}
}
}

function WholeSite(arrayPos) {
alert("function WholeSite(arrayPos) "  + "navigateTo = " + navigateTo);
}

function SpecificSite(arrayPos) {
}

function getInputValue(){
// Selecting the input element and get its value
var inputURL = document.getElementById("myInput").value;
// Displaying the value
navigateTo = inputURL ;
}
</script>

</body>
</html>```

Share on other sites

What's the error you're getting?

Share on other sites

It keeps looping this message :

`alert("SpecificSiteLinks SafeSite = false "+ "navigateTo = " + navigateTo);`

Share on other sites

"keeps looping?" How many times does it loop? Your code as written sends as many alerts as there are sites in specificSiteLinksArray

Share on other sites

```function SpecificSiteLinks(navigateTo) {
SafeSite = false ;
for (var i = 0; i < specificSiteLinksArray.length; i++) {
SafeSite = true ;
break ;
}else {
SafeSite = false ;
}
}
if  (SafeSite == false) {
}
}```

Ok , I see it now ,

Thanks

Edited by vmars316