dhoward007
Programmer
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>
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>