473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Form Redirect to open specified page

Hi all,

I have a small classifieds site and I use the following script to open the
specific ads in a FRAME - "Enter Ad Number".

I have since done away with the frames and the script now has problems.

What I want to do is change it so that it will open in the current window -
and not a FRAME.

Is there a quick fix for this?

<script language="JavaScript">

function AdJump()
{
var vPage;
vPage = document.adjump.adnum.value;
vPage = http://www.anypage.com/photoads/ads + vPage + ".html";
document.open();
document.location.href = vPage;
document.close();

}

</script>
<CENTER>
<FORM NAME="adjump" OnSubmit="AdJump()">
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
<TR><TD WIDTH=10%> &nbsp; </TD>
<TD WIDTH=90% align="center">
<INPUT TYPE="Text" SIZE=3 VALUE="" NAME="adnum"><BR>
Enter Ad Number</FONT>
</TD></TR>
<TR><TD WIDTH=10%> &nbsp; </TD>
<TD WIDTH=90% align="center">
<INPUT TYPE="Submit" VALUE="Submit">
<INPUT TYPE="Reset" VALUE="Reset">
</TD></TR>
</TABLE>
</FORM>
</CENTER>
Jul 23 '05 #1
7 1531


--
--D. McKirahan
DM********@comcast.net
"Von Aras" <te***@ikeras.com> wrote in message
news:qe********************@comcast.com...
Hi all,

I have a small classifieds site and I use the following script to open the
specific ads in a FRAME - "Enter Ad Number".

I have since done away with the frames and the script now has problems.

What I want to do is change it so that it will open in the current window - and not a FRAME.

Is there a quick fix for this?

<script language="JavaScript">

function AdJump()
{
var vPage;
vPage = document.adjump.adnum.value;
vPage = http://www.anypage.com/photoads/ads + vPage + ".html";
document.open();
document.location.href = vPage;
document.close();

}

</script>
<CENTER>
<FORM NAME="adjump" OnSubmit="AdJump()">
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
<TR><TD WIDTH=10%> &nbsp; </TD>
<TD WIDTH=90% align="center">
<INPUT TYPE="Text" SIZE=3 VALUE="" NAME="adnum"><BR>
Enter Ad Number</FONT>
</TD></TR>
<TR><TD WIDTH=10%> &nbsp; </TD>
<TD WIDTH=90% align="center">
<INPUT TYPE="Submit" VALUE="Submit">
<INPUT TYPE="Reset" VALUE="Reset">
</TD></TR>
</TABLE>
</FORM>
</CENTER>


What does "... now has problems" mean?

What you have works for me but I'd change it slightly; watch for word-wrap.

<script type="text/javascript">
function AdJump()
{
var aPage = "http://www.anypage.com/photoads/ads";
var vPage = document.adjump.adnum.value;
location.href = aPage + vPage + ".html";
}
</script>
Jul 23 '05 #2
> What does "... now has problems" mean?
What you have works for me but I'd change it slightly; watch for word-wrap. <script type="text/javascript"> function AdJump() { var aPage = "http://www.anypage.com/photoads/ads"; var vPage = document.adjump.adnum.value; location.href = aPage + vPage + ".html"; } </script>


Thanks Mckirahan,

Because my script was designed for a FRAME - it opens the new page AND THEN
changes to the selected page - leaving an annoying blank page in between the
old and the new page (when not used in a frame).

I can't get it to do anything exactly the way you wrote the changes - but I
will keep playing around with it.

Thanks for the suggestion and the quick answer.

-Von
Jul 23 '05 #3
I actually found a simpler way to do it:
<script type="text/javascript">
function AdJump()
{
window.location.href = http://www.anysite.com/ads/ +
document.getElementById("adnum").value + ".html";

}
</script>

</head>

<body>

<p><input id="adnum" type="text" value size="04"><br>
<button onclick="AdJump()">Enter Ad Number</button><br>
</p>

</body>
Thanks :)
Jul 23 '05 #4
Hmmm.

I just noticed that the submit button doesn't highlight with 'button
onclick' - and you have to manually click the Submit button instead of just
hitting ENTER.

Please disregard my premature jumping-for-joy!

Anyone have any ideas?

Here is the script again:
<script type="text/javascript">
function AdJump()
{
window.location.href = http://www.anysite.com/ads/ +
document.getElementById("adnum").value + ".html";

}
</script>
</head>

<body>

<p>
<input id="adnum" type="text" value size="04"><br>
<button onclick="AdJump()">Enter Ad Number</button><br>
</p>

</body>
Jul 23 '05 #5
"Von Aras" <te***@ikeras.com> wrote in message
news:R9********************@comcast.com...
Hmmm.

I just noticed that the submit button doesn't highlight with 'button
onclick' - and you have to manually click the Submit button instead of just hitting ENTER.

Please disregard my premature jumping-for-joy!

Anyone have any ideas?

Here is the script again:
<script type="text/javascript">
function AdJump()
{
window.location.href = http://www.anysite.com/ads/ +
document.getElementById("adnum").value + ".html";

}
</script>
</head>

<body>

<p>
<input id="adnum" type="text" value size="04"><br>
<button onclick="AdJump()">Enter Ad Number</button><br>
</p>

</body>


Perhaps this variation is what you want?:

<html>
<head>
<script type="text/javascript">
function AdJump() {
var form = document.forms[0];
if (form.adnum.value == "") return false;
form.action = form.action.replace(/#/,form.adnum.value);
return true;
}
</script>
</head>
<body>
<p>
<form action="http://www.anysite.com/ads/#.html"
method="post" onsubmit="return AdJump()">
Enter Ad Number:
<input id="adnum" type="text" value size="4" maxlength="4">
<input type="submit" value="Submit">
</form>
</p>
</body>
</html>

Jul 23 '05 #6
Your code brings back a correct URL - but it doesn't actually work.

I get a 'HTTP 405' error - 'Resource not allowed'.

But if I click the "Go" button again - it works - with the same URL that was
previously generated.

Very strange. :(
Jul 23 '05 #7
"Von Aras" <te***@ikeras.com> wrote in message
news:gP********************@comcast.com...
Your code brings back a correct URL - but it doesn't actually work.

I get a 'HTTP 405' error - 'Resource not allowed'.

But if I click the "Go" button again - it works - with the same URL that was previously generated.

Very strange. :(

Try this
<input name="adnum" type="text" size="4" maxlength="4">

instead of
<input id="adnum" type="text" value size="4" maxlength="4">
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Krechting | last post by:
Hi All, I need a button on my form that opens a new window. I put in a submit button but it always returns to my first page. And then my first page is empty. What button do I need to go to...
3
by: Hans | last post by:
Hi there, I have a number of domain names and they all point to the same IP address. I would like to redirect to a specific folder, based on the domain name used to access the site. For example....
6
by: lukeo | last post by:
I'm shelling out to an .asp (or htm) page from an application. I want to show this in a window without the address bar, etc... Is there a way I can redirect this page using javascript to a page...
3
by: Sehboo | last post by:
On my ASP page, when I click a button, I want to do three things: 1. Check for some values. 2. Open a new window and pass some values as query string. 3. Redirect to some other page Here...
6
by: Joe | last post by:
Hi, I have a MS Access DB in which a record has just too many fields to be able to allow users to do inline editing in a datagrid. So I want to display as First Name: Text box where first...
2
by: John | last post by:
Hi all, After one of my user controls does either a server.transfer or response.redirect, the action method in a my resulting html form is being set and any request variables changed at the...
16
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail...
3
by: =?Utf-8?B?UGF0UA==?= | last post by:
We have a site that gets many requests for nonexistent pages, files and folders. We want those requests redirected to the index page. However, for static files (i.e. images and some other...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.