When I have a coding problem, I generally prefer to check the coding forums I go to before checking other forums with coding boards. It seems like it would make sense, right? I starting to wonder. Nobody in coding forums ever help, but I do often get help with coding issues in other forums with coding boards.
Anyway... here I am, with a javascript question, in a forum that isn't a coding forum, but has a coding board. I've already tried several chatrooms and forums I know of that focusing on coding. Of course, I've had no help. The only people willing to help were people that didn't know the answer.
It has to do with Regexp, seemingly the most difficult thing to learn in javascript. I'm hoping some of you web gurus can help, though.
Basically what it's meant to do is check the end of the url for #content=whatever. When it sees what the whatever is, it tells the rest of the code and runs the proper function to show the correct content.
A friend help me set it up and I've since modified it some, but can't quite get part of it. He threw in the stuff like .+? and RegExp.$1 but I don't understand how they work or what exactly they do. It worked fine when my variable was a number and was always a number. For the sake of organization and ease of finding stuff through my codes, I'd rather use words than numbers to name my content divs. I can't get it to work properly with words. Please help me.
Thank you.
Anyway... here I am, with a javascript question, in a forum that isn't a coding forum, but has a coding board. I've already tried several chatrooms and forums I know of that focusing on coding. Of course, I've had no help. The only people willing to help were people that didn't know the answer.
It has to do with Regexp, seemingly the most difficult thing to learn in javascript. I'm hoping some of you web gurus can help, though.
Code:
<script type="text/javascript">
<!--
var contentName = 'content1';
if (location.href.match(/\#content\=(.+?)/)) {
contentName = RegExp.$1;}
function addend(){eval(contentName+'()');}
// -->
</script>
A friend help me set it up and I've since modified it some, but can't quite get part of it. He threw in the stuff like .+? and RegExp.$1 but I don't understand how they work or what exactly they do. It worked fine when my variable was a number and was always a number. For the sake of organization and ease of finding stuff through my codes, I'd rather use words than numbers to name my content divs. I can't get it to work properly with words. Please help me.
Thank you.





