page redirection

P

Paul

Hi all,

This will hopefully be a really simple question....

I'm a newbie at web app development, and am teaching my self as I go. I have
a page that requires a user to click a
button which then pops up a message box asking the user to make a choice.
Based on this choice, it will either redirect to another page or display a
message. I can get it to display a message, but when it tries to redirect I
get the error;

"Error: Object doesn't support this property or method: 'document.redirect'"

I have tried researching this error but cannot find a solution that works,
can anyone help?

The page code is as follows;

<form>
<INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">

<SCRIPT LANGUAGE="VBScript" >
Sub button_2_onclick
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.write("answer = ")&answer
Else If answer = "7" Then
document.redirect="test2.html"
Else if answer = "2" then
exit sub
End If
End If
End If
End Sub
</SCRIPT>

</form>

Many thanks in advance

Paul
 
P

Paul

Hi all,

sorry to waste your time, I have resolved it myself!!

Changed this line:-
document.redirect="test2.html"
To this:-
document.location.href="test2.html"

thanks again!
 
P

Paul

Ok, after sayng i'm good, i find i'm not!!

Heres the thing....

I have page 1 which has a form on it. when a button is clicked, it passes
the data from the form onto page 2. Thats easy (even for me!), but after
page 2 loads, I need it to popup a message box asking the user to make a
choice and redirect to another page based on the response. When the page
redirects I need it to redirect using values already bought into the page
but cannot pass the values into the script (if that makes sense) Heres how i
have the code on page 2....

<%@ LANGUAGE=VBScript %>
<%Response.Buffer = True%>

<%
Dim var1, var2 and other connection vars

Set objConnString = Server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")
strDSN = "provider=sqloledb;Data Source=BARCA;Initial
Catalog=JellyTracker;User Id=sa;Password=LpmMww2502;"
objConnString.Open strDSN

jtuser = request("user") --> this value is passed via the url string
callres = request("callres") --> this value is collected from the previous
pages form
callnum = request("callnum")--> this value is passed via the url string
closedby = request("closedby") --> this value is collected from the previous
pages form
closetype = request("closetype") --> this value is collected from the
previous pages form
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
</style></head>
<body>
<SCRIPT LANGUAGE="VBScript" >
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.redirect.href="page3.asp?callnum=<%=callnum%>&callres=<%=callres%>"
Else If answer = "7" Then
document.redirect.href="page1.asp?callnum=<%=callnum%>&callres=<%=callres%>"
End If
End If

</SCRIPT>
</body>
</html>

Within the <script> tags, i cannot get the variables <%=callnum%> or
<%=callres%> (or anything else) to show their values, and am completely
stumped, outside the tags, I can see and manipulate them any way I want.

Am I being a bit of a plank here? Is there an easy way for me to do this?

Any help would be appreciated.

Thanks in advance

Paul
 
A

Anthony Jones

Paul said:
Ok, after sayng i'm good, i find i'm not!!

Heres the thing....

I have page 1 which has a form on it. when a button is clicked, it passes
the data from the form onto page 2. Thats easy (even for me!), but after
page 2 loads, I need it to popup a message box asking the user to make a
choice and redirect to another page based on the response. When the page
redirects I need it to redirect using values already bought into the page
but cannot pass the values into the script (if that makes sense) Heres how i
have the code on page 2....

<%@ LANGUAGE=VBScript %>
<%Response.Buffer = True%>

<%
Dim var1, var2 and other connection vars

Set objConnString = Server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")
strDSN = "provider=sqloledb;Data Source=BARCA;Initial
Catalog=JellyTracker;User Id=sa;Password=LpmMww2502;"

I really hope that isn't the real password and its not a good idea to use
the sa account for any of this work. Create a Logon on the SQL server
specifically for this application. Store the connection string and other
utility functions (such as OpenConnection) in an .asp file that your other
files include.
objConnString.Open strDSN

jtuser = request("user") --> this value is passed via the url string
callres = request("callres") --> this value is collected from the previous
pages form
callnum = request("callnum")--> this value is passed via the url string
closedby = request("closedby") --> this value is collected from the previous
pages form
closetype = request("closetype") --> this value is collected from the
previous pages form
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
</style></head>
<body>
<SCRIPT LANGUAGE="VBScript" >
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.redirect.href="page3.asp?callnum= said:
Else If answer = "7" Then
document.redirect.href="page1.asp?callnum= said:
End If
End If

</SCRIPT>
</body>
</html>

Within the <script> tags, i cannot get the variables <%=callnum%> or
<%=callres%> (or anything else) to show their values, and am completely
stumped, outside the tags, I can see and manipulate them any way I want.

Am I being a bit of a plank here? Is there an easy way for me to do this?

Any help would be appreciated.

Are you sure your client are only every going to use IE? Since your just
starting off would it not be better to ensure that your code is more
compatible with other browsers. Personally I'd target IE and FF for
intranet style apps.

What happens when the users press No or Cancel? How do you inform the user
what will happen if the press those buttons?

Basically having dialogs pop-up as part of UIs nominal flow is poor design.
Why not have a interceeding page that displays a confirmation of the
previous forms field entries that then has 3 buttons "Create Call Sheet",
"What ever 'No' would do", "Return to some starting point".

Alternatively have the first page have two buttons "Create Call Sheet",
"What ever no does". The destination page draws which ever form is
appropriate where both forms have a "Get me out here" button.
 
D

Dave Anderson

Paul said:
Hi all,

sorry to waste your time, I have resolved it myself!!

Changed this line:-
document.redirect="test2.html"
To this:-
document.location.href="test2.html"

You should use window.location instead of document.location.
document.location is not part of any standard, while there is at least a
working draft that describes window.location:
http://www.w3.org/TR/Window/#location

See also:

"document.location was originally a read-only property, although Gecko
browsers allow you to assign to it as well. For cross-browser safety,
use window.location instead."

http://developer.mozilla.org/en/docs/DOM:document.location

In any case, you can see for yourself that .redirect is not a method of
*any* DOM object:
http://msdn.microsoft.com/en-us/library/ms533053(VS.85).aspx
 
O

Old Pedant

Works just fine for me.

I have to guess/assume that you don't *REALLY* have any values in your
Request collection.

I created this simple page that I named "junk.asp":

*********** file: junk.asp ************
<%
callnum = Request("callnum")
%>
<HTML><BODY>
<SCRIPT LANGUAGE="VBScript" >
answer = MsgBox ("Click YES to create a call sheet", vbYesNoCancel, "Call
Sheet")
Select Case answer
Case 6 : page = "page3"
Case 7 : page = "page1"
Case Else : page = "invalidChoice"
End Select
location.href = page & ".asp?callnum=<%=callnum%>"
</SCRIPT>
</body>
</html>
**************** end of file **************

Then I invoked the page using
http://localhost/junk.asp?callnum=331188

And, indeed, I got to any of the three pages ("page1.asp", "page2.asp" or
"invalidChoice.asp" with the callnum parameter in place in the query string.
As expected.

So... Cockpit error on your part???

Time for debug???

<%
callnum = request("callnum")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
</style></head>
<body>
DEBUG: Callnum from request was <%=callnum%><HR>

<SCRIPT LANGUAGE="VBScript" >
....
</SCRIPT>
</body>
</html>

Put in DEBUG output of all those values you *THINK* you are getting from the
Request. Maybe you aren't?
 
P

Paul

Well, thanks very much for all your responses.

Err, no thats not my sa username and password, (well not anymore! Cant
believe i left those in there!)

I think I'll be heading down the line of creating additional pages to
complete the task that I need.

Thanks again

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top