View Full Version : Append form input to a URL
stuffdone
05-27-2008, 06:31 PM
I need a script that will take the input from a form text box and insert it to a URL then take the viewer there.
A fixed portion of the url would be:
http://www.domain.com/-p-#.html
The form needs to replace the "#" with a number entered into the text box to produce a url like:
http://www.domain.com/-p-1234.html
Then the SUBMIT button would take the viewer to that URL.
Can be javascript or php. either is just fine with me.
Does anyone know of such a script?
:D
boogyman
05-27-2008, 06:45 PM
<form action="INITIAL_URL" method="get">
<input type="text" name="VARIABLE" value="VALUE">
<input type="submit" value="submit"
</form>
will produce
INITIAL_URL&VARIABLE=VALUE
stuffdone
05-27-2008, 06:47 PM
Thanks. I will experiment with it !
stuffdone
05-27-2008, 06:50 PM
<form action="INITIAL_URL" method="get">
<input type="text" name="VARIABLE" value="VALUE">
<input type="submit" value="submit"
</form>
INITIAL_URL&VARIABLE=VALUE
==
Initial would be:
http://www.domain.com/-p- VALUE
I need .html added after VALUE ? How do I do that?
http://www.domain.com/-p- VALUE.html
Sorry not a programmer !
stuffdone
05-27-2008, 07:02 PM
<form action="INITIAL_URL" method="get">
<input type="text" name="VARIABLE" value="VALUE">
<input type="submit" value="submit"
</form>
INITIAL_URL&VARIABLE=VALUE
The first issue is this inserts a "?" in the URL which breaks it.
Resulting URL has to be clean or won't function.
results exactly like:
http://www.domain.com/-p-VARIABLE.html
Thanks.
boogyman
05-27-2008, 08:00 PM
after reviewing the initial post and this last 2, you are actually going to need to use some javascript, however it will not be accessible to everyone, because every user can disable javascript if they so choose. if you had access to a server-side language like php this could be done, however i am going to assume that you dont, so below is the client-side method
<script type="javascript">
function goToPage(var url = '')
{
var initial = "http://www.domain.com";
var extension = "html";
window.location(initial+url+extension);
}
</script>
<form name="something" action="#">
Label <input type="text" name="url" value="" onchange="goToPage(this.value)">
</form>
stuffdone
05-27-2008, 08:35 PM
after reviewing the initial post and this last 2, you are actually going to need to use some javascript, however it will not be accessible to everyone, because every user can disable javascript if they so choose. if you had access to a server-side language like php this could be done, however i am going to assume that you dont, so below is the client-side method
<script type="javascript">
function goToPage(var url = '')
{
var initial = "http://www.domain.com";
var extension = "html";
window.location(initial+url+extension);
}
</script>
<form name="something" action="#">
Label <input type="text" name="url" value="" onchange="goToPage(this.value)">
</form>
Here is the actual sample. The above did not seem to work for me. I am really the only one it has to work for because the initial page will be loaded locally only, probably not posted on the server at all.
http://www.blossompromotions.com/-p-5004.html ( actual url )
http://www.blossompromotions.com/-p-VARIABLE.html
The script needs to insert the VARIABLE then redirect to the complete URL shown or such other as would result with various numbers entered.
Thanks guy...appreciate your help.
stuffdone
05-27-2008, 08:57 PM
This is what appears in the address bar:
file:///J:/1-WORK/1_Web_Sites/Pool/blossom1.html?url=5005#
What should appear is:
http://www.blossompromotions.com/-p-5005.html
Should not be dependent on the physical location of the script as it will be used locally from desktop, not from the server.
stuffdone
05-27-2008, 09:05 PM
I placed a <BASE REF in the header. It does not go to the correct domain, however the URL contains a "?" as:
http://www.blossompromotions.com/?url=5005#
It needs to be
http://www.blossompromotions.com/-p-5005.html
I will try again with the base including the /-p- and see what happens
stuffdone
05-27-2008, 09:26 PM
<HTML>
<HEAD>
<SCRIPT type="javascript">
function goToPage(var url = '')
{
var initial = "http://www.blossompromotions.com/-p-";
var extension = "html";
window.location(initial+url+extension);
}
</SCRIPT>
<TITLE>Redirect 1</TITLE>
<BASE HREF="http://www.blossompromotions.com/">
</HEAD>
<BODY>
<P>
<FORM name="something" action="#">
Label
<INPUT type="text" name="url" value="" onSubmit="goToPage(this.value)">
<INPUT type="submit" value="GO">
</FORM>
</BODY></HTML>
=====
It will load the correct domain but the URL is still not correct. It results in this. ( example input 5005 )
http://www.blossompromotions.com/?url=5005#
Should be:
http://www.blossompromotions.com/-p-5005.html
===/ note /===
This seems to work same:
<SCRIPT type="javascript">
function goToPage(var url = '')
{
window.location(http://www.blossompromotions.com/-p-+url+.html);
}
</SCRIPT>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.