From: Geoff Cox on
Hello

I cannot see why this is not working - the idea being to check the
email address entered and if OK to move to either one of 2 pages - the
move does not happen.

The code below is in the lower of 2 frames.

Why?!

Cheers

Geoff


function getNextPage(){
var num = Math.random();
if (num<.5) {
location.href="group1/group1-lab1.htm";
} else {
location.href="group2/group2-lab1.htm";
}
}

function validateEmail ( emailField, errorMsg ) {
emailpat =
/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
if( !emailpat.test( emailField.value ) ) {
alert( errorMsg);
emailField.focus();
emailField.select();
return false;
} else {
getNextPage();
}
}

//-->
</script>

</head>

<body>

<h2>test</h2>

<form name="emailForm" onsubmit="validateEmail( this.email , 'Please
enter a valid email address')">
Please enter your email address <input type="text" name="email">
<input type="submit" value="enter">
</form>
From: Stevo on
Geoff Cox wrote:
> I cannot see why this is not working - the idea being to check the
> email address entered and if OK to move to either one of 2 pages - the
> move does not happen.

The simplest way to find out is to add alerts throught. That shows the
path the code is taking, and if you alert the values of things too,
it'll show you why. Example:

function getNextPage(){
var num = Math.random();
alert("in getNextPage, random num="+num);
if (num<.5) {
alert("in getNextPage, following<.5 logic")
location.href="group1/group1-lab1.htm";
} else {
alert("in getNextPage, following else logic")
location.href="group2/group2-lab1.htm";
}
}
From: Geoff Cox on
On Mon, 05 May 2008 11:47:59 +0200, Stevo <no(a)mail.invalid> wrote:

>Geoff Cox wrote:
>> I cannot see why this is not working - the idea being to check the
>> email address entered and if OK to move to either one of 2 pages - the
>> move does not happen.
>
>The simplest way to find out is to add alerts throught. That shows the
>path the code is taking, and if you alert the values of things too,
>it'll show you why. Example:
>
>function getNextPage(){
>var num = Math.random();
>alert("in getNextPage, random num="+num);
> if (num<.5) {
> alert("in getNextPage, following<.5 logic")
> location.href="group1/group1-lab1.htm";
> } else {
> alert("in getNextPage, following else logic")
> location.href="group2/group2-lab1.htm";
> }
>}

Thanks Stevo, I have tried your code but still not clear why my code
isn't working!

After

alert("in getNextPage, following<.5 logic")

I just see the original email address input and not

group1/group1-lab1.htm

Where next?!

Cheers

Geoff
From: Geoff Cox on
On Mon, 05 May 2008 11:23:38 +0100, Geoff Cox <gcox(a)freeuk.notcom>
wrote:

re

function getNextPage(){
var num = Math.random();
alert("in getNextPage, random num="+num);
if (num<.5) {
alert("in getNextPage, following<.5 logic")
location.href="group1/group1-lab1.htm";
} else {
alert("in getNextPage, following else logic")
location.href="group2/group2-lab1.htm";
}
}

I should have written that after seeing either

alert("in getNextPage, following<.5 logic")

or

alert("in getNextPage, following else logic")

I just get the original page back - no move to the new page?!

Cheers

Geoff

From: Geoff Cox on
On Mon, 05 May 2008 11:47:59 +0200, Stevo <no(a)mail.invalid> wrote:

>Geoff Cox wrote:
>> I cannot see why this is not working - the idea being to check the
>> email address entered and if OK to move to either one of 2 pages - the
>> move does not happen.
>
>The simplest way to find out is to add alerts throught. That shows the
>path the code is taking, and if you alert the values of things too,
>it'll show you why. Example:
>
>function getNextPage(){
>var num = Math.random();
>alert("in getNextPage, random num="+num);
> if (num<.5) {
> alert("in getNextPage, following<.5 logic")
> location.href="group1/group1-lab1.htm";
> } else {
> alert("in getNextPage, following else logic")
> location.href="group2/group2-lab1.htm";
> }
>}


Stevo,

I seems that the

location.href="group1/group1-lab1.htm";

or the

location.href="group2group2lab1.htm";

is wrong - but they seem Ok to me ...?

Cheers

Geofg