Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Turn form submit into URL
Old 05-15-2005, 05:54 PM Turn form submit into URL
Average Talker

Posts: 15
Trades: 0
Hi Everybody

I have this site called Statbrain.com and I have a Javascript problem that I just can’t solve. It is a pretty annoying problem because it 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:
http://www.statbrain.com/result.php5...=www.yahoo.com

But that is not what I want. I want the user to be forwarded to:
http://www.statbrain.com/www.yahoo.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

Please login or register to view this content. Registration is FREE

FREE Tells you how many visitors any website has.
ZachH is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-15-2005, 06:56 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
It's strange that it window.location didn't work in FireFox. Could you perhaps post the code that you've already tried?
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 05-15-2005, 07:21 PM
Average Talker

Posts: 15
Trades: 0
Here it goes:
<input class='standard' type="submit" value="Check" onclick="window.location='http://www.statbrain.com/'+document.getElementById('domain').value+'/'">
__________________
Zach Highknee

Please login or register to view this content. Registration is FREE

FREE Tells you how many visitors any website has.
ZachH is offline
Reply With Quote
View Public Profile
 
Old 05-15-2005, 07:58 PM
Average Talker

Posts: 15
Trades: 0
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.
__________________
Zach Highknee

Please login or register to view this content. Registration is FREE

FREE Tells you how many visitors any website has.
ZachH is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Turn form submit into URL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13430 seconds with 12 queries