Forums

This topic is locked

Page Redirect based on table information

Posted 23 Dec 2002 12:23:24
1
has voted
23 Dec 2002 12:23:24 Kent Steelman posted:
I am in the process of creating an administrative page for a client. There is a search portion and a results portion at this time. Each of the clients users are allow up to five submittals at anyone given time. The results page shows who and how many submittals are available. What I would like to to is redirect them to the submittal page if the number of submittals is greater than zero and if zero send them to another page so they can delete one submittal before adding another. At this point the results page properly shows the number of available submittals, what I need is a way to change the page hot link/redirect to the other page when the value is 0.

Wm. Kent Steelman

Replies

Replied 23 Dec 2002 12:43:21
23 Dec 2002 12:43:21 Owen Eastwick replied:
If you want to show an appropriate link on the search results page:

<%
If varSubmitalsLeft = 0 Then
Response.Write("<a href='DeleteSubmital.asp'>Delete a submital</a>"
Else
Response.Write("<a href='Submital.asp'>Make a submital</a>"
End If
%>


If you want to automatically redirect to the appropriate page:

<%
If varSubmitalsLeft = 0 Then
Response.Redirect("DeleteSubmital.asp"
Else
Response.Redirect("Submital.asp"
End If
%>

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 23 Dec 2002 13:51:47
23 Dec 2002 13:51:47 Kent Steelman replied:
Thanks for the information and the code/logic. I will try it. Two questions came to mind,
1. The first example will apply if the user clicks on the number/prompt?
2. Where in my code do I insert the IF -:> Then -:> Else

Wm. Kent Steelman
Replied 23 Dec 2002 17:17:22
23 Dec 2002 17:17:22 Owen Eastwick replied:
The first example will show a link.

Like this if they have reached the submital limit:

<u>Delete a submital</u>

Like this if they havent:

<u>Make a submital</u>

The code should be placed where you want the links to appear.

In my example I have stored the number of submital in a variable: <b>varSubmitalsLeft</b>, you will have to adapt this so that it refers to the number of submitals left, retreived or calculated from your search results recordset, you don't show that so I don't know exactly how you've done it.

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 23 Dec 2002 22:30:09
23 Dec 2002 22:30:09 Kent Steelman replied:
Thanks for all of your help and patients. Below will be the code that is in my page. It is simple with a 2 row, 4 column table. There is a repeat region that will display varibles that are determined by a MS Access database query. The query calculates the remaining images the user will be allowed to add. Based on the value of the result, the user will be able to move to one of two pages by clicking on the number, range is from 0 to 5. As an example if a 4 is displayed in the column, the 4 is underlined and if clicked will send the user to a page that will allow them to add another image. If value is 0 and the user clicks on the "0", which is also underlined and the user is send to a different page that tells them to delete one or more of the images before adding the new image. Below is the code for the page.

&lt;%@LANGUAGE="VBSCRIPT"%&gt;
&lt;!--#include file="../../../Connections/caliconnection.asp" --&gt;
&lt;%
set rsLadyResults = Server.CreateObject("ADODB.Recordset"
rsLadyResults.ActiveConnection = MM_caliconnection_STRING
rsLadyResults.Source = "SELECT * FROM qry_lady_profile_pictavail"
rsLadyResults.CursorType = 0
rsLadyResults.CursorLocation = 2
rsLadyResults.LockType = 3
rsLadyResults.Open()
rsLadyResults_numRows = 0
%&gt;
&lt;%
Dim Repeat1__numRows
Repeat1__numRows = 10
Dim Repeat1__index
Repeat1__index = 0
rsLadyResults_numRows = rsLadyResults_numRows + Repeat1__numRows
%&gt;
&lt;%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName &lt;&gt; "" Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth &lt;&gt; "" Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL &lt;&gt; "" Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm &lt;&gt; "" Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem &lt;&gt; "" Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;table width="550" border="2" cellspacing="1" cellpadding="1" align="left" height="50"&gt;
&lt;tr&gt;
&lt;td width="25%" height="49"&gt;&lt;b&gt;&lt;font size="2"&gt;Last Name/ Apellido&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td width="30%" height="49"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;First Name/ Primer Nombre&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="30%" height="49"&gt;&lt;b&gt;&lt;font size="2"&gt;Middle Name/ Segundo Nombre&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td height="49" width="20%"&gt;
&lt;div align="center"&gt;&lt;b&gt;&lt;font size="2"&gt;Picture / Avail&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsLadyResults.EOF))
%&gt;
&lt;tr&gt;
&lt;td width="25%"&gt;&lt;A HREF="client_update_form_lady.asp?&lt;%= MM_keepNone & MM_joinChar(MM_keepNone) & "Availwoman_id=" & rsLadyResults.Fields.Item("Availwoman_id".Value %&gt;"&gt;&lt;font size="2"&gt;&lt;%= UCase((rsLadyResults.Fields.Item("LastName".Value)) %&gt;&lt;/font&gt;&lt;/A&gt;&lt;/td&gt;
&lt;td width="30%"&gt;&lt;font size="2"&gt;&lt;%= UCase((rsLadyResults.Fields.Item("FirstName".Value)) %&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="30%"&gt;&lt;font size="2"&gt;&lt;%= UCase((rsLadyResults.Fields.Item("MiddleName".Value)) %&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="20%"&gt;
&lt;div align="center"&gt;&lt;A HREF="client_lady_pictureupload.asp?&lt;%= MM_keepBoth & MM_joinChar(MM_keepBoth) & "Availwoman_id=" & rsLadyResults.Fields.Item("Availwoman_id".Value %&gt;"&gt;&lt;%=(rsLadyResults.Fields.Item("PictAvail".Value)%&gt;&lt;/A&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsLadyResults.MoveNext()
Wend
%&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsLadyResults.Close()
%&gt;


Wm. Kent Steelman

Reply to this topic