Forum Moderators: open

Message Too Old, No Replies

Turn form submit into URL

Annoying simple problem that should have simple solution

         

ZachH

10:03 pm on May 15, 2005 (gmt 0)

10+ Year Member



Hi Everybody

I have this annoying JavaScript problem that should be so simple. It might be simple, but I just can’t figure out how to solve it.

Let me explain.

I have this field where the users can put an URL into a form and click the submit button and the info for that site will be show. If you were checking www.yahoo.com the user would be forwarded to this page:
[mysite.com...]

But that is not what I want. I want the user to be forwarded to:
[mysite.com...]

Both of the pages give the same result, but I want the second one for different reasons. Before you say this is a piece of cake let me tell you what I’ve tried so far.

First I tried to use OnClick and window.location and window.location.href. This worked ok, but only in IE it did not work in Firefox at all. It has to work in Firefox since 20% of my visitors use Firefox.

Then I tried to use OnClick and this.form.action. This did work in IE, but pressing enter to submit the for did not work.

Anyone who has a good and simple idea on how I can solve this?

Sorry about the long post, tried to do it as short as possible.

Regards,

Zach Highknee
Statbrain

ZachH

10:57 pm on May 15, 2005 (gmt 0)

10+ Year Member



Someone in another forum found a solution:
<form action="" onsubmit="var loc='http://www.statbrain.com/'+this.elements[0].value+'/';location.href=loc;return false">

Works like a dream.

Thanks.

TheRookie

11:01 pm on May 15, 2005 (gmt 0)

10+ Year Member



Glad we could help!

;-)