^ title.
How do u get that script?? So that my users type in a URL in a text form box and click submit, it goes to the website. thx
| Code: |
| document.location.href = document.form_name.textbox_name.value; |
ah yes thank u sir for ur reply!
is there anyway i can automatically make the person go to a url but instead of typing it all out. have them just type the last part of it. FOR EXAMPLES
like msn.com/cars .... have them just type cars in the box and it will go to msn.com/cars
or type just weather and it goes to msn.com/weather
that kind of thing
BTW where do i put the code u gave me and whats it called
| dz9c wrote: |
ah yes thank u sir for ur reply!
is there anyway i can automatically make the person go to a url but instead of typing it all out. have them just type the last part of it. FOR EXAMPLES
like msn.com/cars .... have them just type cars in the box and it will go to msn.com/cars
or type just weather and it goes to msn.com/weather
that kind of thing
BTW where do i put the code u gave me and whats it called |
You can use PHP like:
| Code: |
<?php
$url=$_POST['url'];
if ($url == "car") header("Location: http://www.msn.com/cars/");
elseif ($url == "weather") header("Location: http://www.msn.com/weather/");
else echo "No such url or something else.";
?> |
Of course you need form which uses PHP-function.
Ok...the two other examples are probably pretty hard to understand...here's an easy one which uses simple HTML & javascript:
| Code: |
<input type="text" id="url_field" size="15" />
<input type="submit" value="Go there!" onclick="window.location='http://'+document.getElementById('url_field').value; return false;" />
|
The only problem here is that it relies on the user not typing in "http://"
You could easily test this with javascript - write if you want me to help you.
| Quote: |
ah yes thank u sir for ur reply!
is there anyway i can automatically make the person go to a url but instead of typing it all out. have them just type the last part of it. FOR EXAMPLES
like msn.com/cars .... have them just type cars in the box and it will go to msn.com/cars
or type just weather and it goes to msn.com/weather
that kind of thing
BTW where do i put the code u gave me and whats it called |
Ok...just change what it says in line 2...where it says "http://" change it to "http://www.msn.com/"
The code isn't really called anything...though its written in Javascript...call it what you like 
hmm ok so i could do that thing with the code:
| Code: |
<input type="text" id="url_field" size="15" />
<input type="submit" value="Go there!" onclick="window.location='http://'+document.getElementById('url_field').value; return false;" /> |
now i just need one more thing... a minimum amount of text script for the url field? will pay u some frih$ maybe
Yea...just put that anywhere in the code...
Why do you want a minnimun text length?
It wouldnt be hard to make, but shouldnt visitors be allowed to go anywhere they want??
If your certain that you want it i will change it to a function and we can test the text in all sorts of fun ways...
[looks in his at signature]
No need for any frih$ methinks...
You could write a function for this purpose:
| Code: |
function box_search(url){
// Validate length
if(document.getElementById('url_field').value.length > 6){
alert('The text you entered in the field was too long!');
} else {
location.href = 'http://'+url;
}
}
|
The HTML section:
| Code: |
<input type="text" id="url_field" size="15" />
<input type="button" value="Go there!" onclick="box_search('www.example.com')" /> |
naw ok you see, heres exactly wat im trying to do...
im trying to make it so that theres one text box on the page, they type in a 8 character long number like "45984707" and that is an ID. the id will be added to the url of "http://www.myspace.com/" and go to the page
http://www.myspace.com/45984707" for this example. its for this myspace thing im doing that i will show u wen im done, which if u have myspace, u will like what im making.
so if i want to go to: "http://www.myspace.com/45984707"
all i want to have to do is type in 45984707 in one text box and press a button.
THIS WOULD BE SERIOUSLY APPRECIATED! i will give like all my frihs to anyone who helps me with that. i know its easy but i dont kno exactly how its done.
or if you want to do it in java script you can use this code: | Code: |
<form name="jumpurl1" onSubmit="return jumpit()">
<input type="text" size=30 name="jumpurl2" value="http://">
<input type="button" value="Go!" onClick="jumpit()">
</form>
<script>
/*
URL jump box
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/
function jumpit(){
window.location=document.jumpurl1.jumpurl2.value
return false
}
</script>
<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p> |
Its from javascript kit.
hmm ok cool thats a start. thats a great start just need to twaek this somehow to make it so that they dont need to type http:// and all that other crap. i need there to be an initial url and so that watever the user types in the box just gets added on the initial url and goes to that.
FOREXAMPLE:
somehow make
-http:// the initial url.
-then all the user needs to do is type www.myspace.com or whatever the heck they want to go
-it then becomes http://www.myspace.com and goes to that
after where it says window.location= add:
Thats all there is to it!
YES THATS IT! HAHA THANK U BOTH. 90 / 2 = 45 for both of u!