Form Submit changes url variable

SpaceshipSpaceship
Watch

ridesign1

Established Member
Impact
7
Hi,
Is it possible to create a page where a user would type in a number in a box and press submit e.g. 12

and then it goes to the url: http://www.newdesignworld.com/browse-12.html


Any code would be great :)

thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I would do this:

<form action="redirect.php" method="post">
<input type="text" name="page" value="123" />
<input type="submit" />
</form>

then on redirect.php:
PHP:
<?php
$page = $_POST['page'];
settype($page,"integer");
header("Location: http://www.newdesignworld.com/browse-".$page.".html");
?>

You might be able to do it with javascript, not needing a php page. I'll try making something...

edit:
Haven't tested, but should work:
Code:
<script>
function doSomething (form) {
var pageNum = parseInt(form.page.value);
window.location = "http://www.newdesignworld.com/browse-" + pageNum + ".html";
}
</script>
<form action="" method="post">
<input type="text" name="page" value="123" />
<input type="submit" onClick="doSomething(this.form);" />
</form>
 
Last edited:
0
•••
thanks jim,
the first one worked using the php file, but with the 2nd one, i added that to a page but it just comes back to the same page.
 
0
•••
try adding onsubmit="this.disable=true;" to the <form> tag on the javascript version.
 
0
•••
Maybe instead of:
var pageNum = parseInt(form.page.value);
use
var pageNum = parseInt(getElementById('page').value);

and add id="page" to the input.
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back