Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript stack erro

Status
Not open for further replies.

bryanfl100

Technical User
Dec 2, 2005
17
US
Is there a way to stop the following javascript from giving a stack error? Also the onclick="bookNow('airlines.id%3D$data[airlines.id]') cannot change.

<script>
function bookNow(s) {
if ( s.match('Delta') ) {
bookNow(s);
} else {
alert('call us');
}
}
</script>

<a href="#" onclick="bookNow('airlines.id%3D$data[airlines.id]'); return false;">BOOK NOW</a>
 
of course you're getting a stack overflow... if the first condition is met, you're simply calling the same function again with the same input, which meets the first condition, ad infinitum

solution? do something different

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Check out the phrase "infinite recursion" in a search engine to see why you get this error.

I suspect you DON'T want to call the bookNow function in itself, but have a separate function you didn't show, or haven't written yet.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top