Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change response.redirect dynamically?

Status
Not open for further replies.

dhoward007

Programmer
Feb 6, 2002
45
US
Is there a way to change the page response.redirect sends the user to?

I have a combo box that has a list of values and depending on what the user selects, I am refreshing the page and running a db query to get the file to redirect the user to based on their selection.

Below is the code to the page. Is there a way to do this using vbscript? or do I have to use js?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script language="vbscript">
Sub cboDBAGroup_OnChange
ChooseOnCallEdit.action = "ChooseOnCallEdit.asp"
ChooseOnCallEdit.submit()
End Sub
</SCRIPT>
<%
'Get the connection Info from Application Variable.
sDBConnect = Application("gsSQLConfigs")

'Set Variables
Dim strRedirectFileName
Dim strDBAGroupSelected
'Build the Query for the Combo Box.
strCboQry = "select dbagroup, dbaeditfile from dbagroups"
Set rsCboDBAGroup = CreateObject("adodb.Recordset")
rsCboDBAGroup.Open strCboQry, sDBConnect, adOpenForwardOnly



IF len(request.form("cboDBAGroup")) > 0 THEN
strDBAGroupSelected = request.form("cboDBAGroup")
response.write strDBAGroupSelected & "<br>"
'Now if you have selected a group, now build a query to get the file for
'redirecting the user to edit the group
strFileQry = "select dbaeditfile from dbagroups where dbagroup = '" & strDBAGroupSelected & "'"
Set rsFileName = CreateObject("adodb.Recordset")
rsFileName.Open strFileQry, sDBConnect, adOpenForwardOnly
response.write rsFileName("dbaeditfile")
strRedirectFileName = rsFileName("dbaeditfile")
response.redirect ("""" & strRedirectFileName & """")

ELSE

response.write "No DBA Group Selected"
END IF

%>

<html>
<head>
<title>Choose On Call Group To Modify</title>
</head>
<form name="ChooseOnCallEdit" ID="ChooseOnCallEdit" method="post" action="ChooseOnCallEdit.asp?">
<body>
<center>Select The DBA Group That you want to edit.</center>
<P>
<br>
<center>
<select name="cboDBAGroup">
<option> </option>
<% Do Until rsCboDBAGroup.EOF %>
<% IF ltrim(rsCboDBAGroup("DBAGroup")) = strDBAGroupSelected Then%>
<option value="<%=rsCboDBAGroup("DBAGroup")%>" selected="selected"><%=rsCboDBAGroup("DBAGroup")%></option>
<%ELSE%>
<option value="<%=rsCboDBAGroup("DBAGroup")%>"><%=rsCboDBAGroup("DBAGroup")%></option>
<%END IF%>
<% rsCboDBAGroup.MoveNext %>
<%LOOP%>
</select>
<%rsCboDBAGroup.Close%>

</center>
</body>
</form>
</html>


 
Let's not make things any harder than they already are!!


try this
Code:
response.redirect strRedirectFileName

also you can't do response.redirect after you have already written to the page

response.write rsFileName("dbaeditfile")


 
I tried the fix above and I get a 404 error.. The page does exist but I cannot figure out why it will not work.


If I hard code the page it works..


any clues?

response.redirect "editoncall.asp"
 
You have answered it yourself - page 404 (page not found), check the location of editoncall.asp, is it in the same folder?

Simon
 
or change response.redirect strRedirectFileName
to response.write strRedirectFileName to make sure the variable is being populated as expected. That's where I've often run into trouble.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top