Form Handle and redirection.

They have: 2 posts

Joined: Sep 2001

I am having a brain fart and can't seem to figure something out....

I want to pop a window upon form submission to a URL depending upon a value of a particular field. How can I make this happen in a JavaScript??

If field "name" equals "1" then when the user clicks submit it will pop a new window with URL

If field "name" equals "2" then same function but different URL.

Now, if field is anything other than "1" or "2" I don't want any pops.......

IF anyone can help I'd appreciate it.....I've tried a few things but can't get it to work correctly.....

Justin

Brian Farkas's picture

They have: 1,015 posts

Joined: Apr 1999

I'm moving this post to the web site authoring forum, since that is where it seems to belong (question about JavaScript).

They have: 2 posts

Joined: Sep 2001

Hi,

Try this, may be it will work.

<script language="javascript">
function win()
{if (document.myform.number.value == "1")
{window.open("http://URL1","win");}
else
{window.open("http://URL2","win");}
}
</script>

1
2

Replace URL1 and URL2 with your desired urls.
Best of Luck.

Regards,

Smiling UP.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Welcome to TWF, Uma Parvati!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

....whatever html....

function doIt(formObj)
{
var newUrl = "";
...do whatever validation you want to do...
switch (formObj.fieldname.value)
{
case '1':
newUrl = 'http://members.aol.ocm/grassblad';
break;
case '2':
newUrl = 'http://members.aol.ocm/grassblad';
break;
}
if (newUrl.length > 1)
var myPop = window.open(newUrl,"", windowFeatures);
}

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.