I have a little snippet of code that works fine when I run it locally on my computer.When I upload it to my site it doesn't work. I cut and pasted the code directly from one file to the other. The only difference is that when the code is online it is within a bunch of other stuff. I am wondering if anybody could take a look at the source and tell me if theres anything obvious...
this is in the body tag, right after <body>
Code:
<script language="javascript">
<!-- Begin
function findEmailAddresses(StrObj) {
var separateEmailsBy = "\n ";
var email = "<none>"; // if no match, use this
var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
if (emailsArray) {
email = "";
for (var i = 0; i < emailsArray.length; i++) {
if (i != 0) email += separateEmailsBy;
email += emailsArray[i];
}
}
return email;
}
// End -->
</script>
then later on I have this:
Code:
<form name='form'>
<textarea name=comments rows=10 cols=50></textarea>
<br>
Emails in this documnet<br>
<textarea name=email rows =10 cols=50></textarea>
<BR><BR>
<INPUT TYPE=button VALUE='Clear Data' NAME=button1 onclick=this.form.comments.value=''>
<INPUT TYPE=button VALUE='Find Emails' NAME=button2 onclick=this.form.email.value=findEmailAddresses(this.value);>
</form>
the button that looks for email addresses does not work and I can't figure out why. Any idears??? Probably something simple...
James