Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2003, 01:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default searching option problem, please help

Hi everyone!

Searching option problem
Please help what is search coding if more files involve.
I want that when I entery the contractno it redirect to contract no file
If I entery recordno it redirect to recordno file
if I entery categroy it redirect to category file with category's value.

what will be response.redirect coding.
Please help

 <%
contractno=Request.QueryString("contractno")
contractno=Request.QueryString("contractno")
recordno=Request.QueryString("recordno")
recordno=Request.Form("contractno")
category=Request.Form("category")
category=Request.QueryString("category")

if contractno=contractno then
Response.Redirect("contno.asp?contractno")

else

Response.Redirect("searchpage.asp")

 if recordno=recordno then
 Response.Redirect("recordno.asp?recordno")

 else

 Response.Redirect("searchpage.asp")

 if category=category then
 Response.Redirect("category.asp?category")

else

Response.Redirect("searchpage.asp")


end if
end if
end if

%>


 best regards.

Mateen Martin
[email protected]
 
Old June 7th, 2003, 03:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Hmm.. I am not sure that I understood, but maybe you want this...
On page1.asp you have three options, and after user's choosing you have to redirect him to chosen page. Here is the code for this.

Code:
<html>
<body>
<%
If Request.Form("file_name")="" Then

%>
<form action=page1.asp method=post>
Please choose an option:<br>
<input type=radio name=file_name value=contractno>contractno<br>
<input type=radio name=file_name value=recordno>recordno<br>
<input type=radio name=file_name value=category>category<br>
<input type=submit value=Submit>
</form>
<%
Else
redirected_file_name=Request.Form("file_name") & ".asp"
Response.Redirect redirected_file_name
End If
%>
</body>
</html>
...but the Soon is eclipsed by the Moon
 
Old June 9th, 2003, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response.
I have to select multiple select option,
which select option I select it redirect to
that page. what will loop condition, please
help.


<%
projectno=Request.QueryString("projectno")
recordno=Request.QueryString("recordno")
image=Request.QueryString("image")

projectno=Request.Form("projectno")
recordno=Request.Form("recordno")
image=Request.Form("image")

if projectno=projectno then

Response.Redirect("projectno.asp?projectno")

else

 Response.Redirect("wpls.asp")

 if recordno=recordno then

 Response.Redirect("recordno.asp?recordno")

 else

 Response.Redirect("wpls.asp")

end if
end if
end if
%>


regards.

Mateen Martin
[email protected]




Quote:
quote:Originally posted by NotNowJohn
 Hmm.. I am not sure that I understood, but maybe you want this...
On page1.asp you have three options, and after user's choosing you have to redirect him to chosen page. Here is the code for this.

Code:
<html>
<body>
<%
If Request.Form("file_name")="" Then

%>
<form action=page1.asp method=post>
Please choose an option:<br>
<input type=radio name=file_name value=contractno>contractno<br>
<input type=radio name=file_name value=recordno>recordno<br>
<input type=radio name=file_name value=category>category<br>
<input type=submit value=Submit>
</form>
<%
Else
redirected_file_name=Request.Form("file_name") & ".asp"
Response.Redirect redirected_file_name
End If
%>
</body>
</html>
...but the Soon is eclipsed by the Moon
 
Old June 10th, 2003, 10:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

If you have one select option field (combo box) on the page for selecting an option, and if the name of this field is select_option, then you can handle the selected value as following:

if select_option="contractno" then
Response.Redirect contractno.asp
end if

and so on for the other options.

 
Quote:
quote:if projectno=projectno then

This is always true, so you can't use it for the redirection.

Quote:
quote:contractno=Request.QueryString("contractno")
contractno=Request.Form("contractno")
This means that the variable contractno has the value equal to Request.Form("contractno") i.e. the variable's value is overwritten by the second statement.

HTH ,
NotNowJohn
P.S. If the prob occurs again, please send me an email with full code.

...but the Soon is eclipsed by the Moon
 
Old June 11th, 2003, 03:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response.

Please check the following asp file in the localhost just for demo. Due to connect (data) problem it will not show the data (list).
I want that I select the option, it will redirect to that page.
What logic / coding will apply.
firstfile.asp condition.asp contractno.asp recordno.asp category.asp

If I select contractno option, it redirect to contractno.asp
If I select recordno option it redirect to recordno.asp
If I select category option it redirect to category.asp


================================================== =======

                            First page
<html>
</HEAD>
<body>
<form method=post action=search2.asp id=form name=form>

<INPUT style="WIDTH: 48px; HEIGHT: 24px" type=submit size=16 value=search id=submit1 name=submit1><INPUT style="WIDTH: 48px; HEIGHT: 24px" type=reset size=16 value=clear id=submit1 name=submit1>

<TABLE cellSpacing=1 cellPadding=1 width="680" border=1 bordercolorlight="#CCCCCC" bordercolordark="#666666">

  <TR>
    <TD width="231">Contract No :</TD>
    <TD width="333"><SELECT id=contractno name=contractno> <OPTION selected>
<%
dim ssql

set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"
cn.Open

contractno=Request.QueryString("contractno")

ssql="select distinct contractno from archive2 order by contractno"

set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("contractno") & "'>")
Response.Write(rs("contractno") )
rs.movenext
loop
%>

  </OPTION></SELECT></TD></TR>
    <TR>
    <TD width="231">Record Drawing No :</TD>
    <TD width="333"><SELECT id=recordno name=recordno><OPTION selected>
    <%

set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"
cn.Open

ssql="select distinct recordno from archive2 order by recordno"

set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("recordno") & "'>")
Response.Write(rs("recordno") )
rs.movenext
loop
%>

  </OPTION></SELECT></TD></TR>
  <TR>

    <TD width="231">Drawings Category :</TD>
    <TD width="333"><SELECT id=category name=category> <OPTION
  selected>
    <%

ssql="select distinct category from archive2 order by category"

set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("category") & "'>")
Response.Write(rs("category") )
rs.movenext
loop
%>

  </OPTION></SELECT></TD></TR>
  <TR>

    </TD></TR></TABLE>

</P>


</form>

</BODY>
</HTML><body background="images/radbkgnd.gif" bgcolor="#FFFFFF" text="#000000" link="#6666FF" vlink="#993333" alink="#66CCCC"></body>

================================================== =====================
                                    second page
what condition / coding will use to redirect the next page, which was selected from firstpage, please send.

.....

....







================================================== =======================

                            third page
get the value from the second page, and display the result. as need.


<html>
<HEAD>
</HEAD>
<BODY>

<form method=post action=wpls.asp id=form name=form>
<%

set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"
cn.Open

contractno=Request.QueryString("contractno")
contractno=Request.Form("contractno")

recordid=Request.Form("recordid")

if rs="" then
rs="-"
end if


ssql="SELECT * FROM archive2 where contractno='" &contractno & "'"

'Record Set
set rs=cn.Execute(ssql)

%>
<TABLE border=1 bordercolorlight="#669999" bordercolordark="#330066">
<tr bgcolor=gold>
<th>Contract No</th>
<th>Record Drawing No</th>
<th>Description</th>
<th>Drawing Category</th>
<th>Contractor</th>
<th>Consultant</th>
<th>Drawing No</th>
<th>ImageReference</th>
<th>Window_x1</th>
<th>Window_y1</th>
<th>Window_x2</th>
<th>Window_y2</th>
</tr>

<%

images_dir="images/"




do while NOT rs.EOF

image_URL=images_dir & rs("imagereference")

Response.Write("<tr>")
Response.Write("<td bgcolor=lightyellow>" & rs("contractno") & "</td>")
Response.Write("<td>" & rs("recordno") & "</td>")
Response.Write("<td>" & rs("description") & "</td>")
Response.Write("<td>" & rs("category") & "</td>")
Response.Write("<td>" & rs("contractor") & "</td>")
Response.Write("<td>" & rs("consultant") & "</td>")
Response.Write("<td>" & rs("drawingno") & "</td>")

Response.Write("<td>")
Response.Write("<a href=" & server.URLEncode(rs("imagereference")) & ">" & rs("imagereference") & "</a>")
Response.Write("</td>")

Response.Write("<td>" & rs("window_x1") & "</td>")
Response.Write("<td>" & rs("window_y1") & "</td>")
Response.Write("<td>" & rs("window_x2") & "</td>")
Response.Write("<td>" & rs("window_y2") & "</td>")


Response.Write("<tr>")
rs.movenext
loop
%>
</TABLE>

<INPUT id=submit2 name=submit2 type=submit value="Back" target=Right>
</P>
<P>&nbsp;</P>
</BODY>
</HTML>

</body>

regards.

Mateen Martin



Quote:
quote:Originally posted by NotNowJohn
 Hmm.. I am not sure that I understood, but maybe you want this...
On page1.asp you have three options, and after user's choosing you have to redirect him to chosen page. Here is the code for this.

Code:
<html>
<body>
<%
If Request.Form("file_name")="" Then

%>
<form action=page1.asp method=post>
Please choose an option:<br>
<input type=radio name=file_name value=contractno>contractno<br>
<input type=radio name=file_name value=recordno>recordno<br>
<input type=radio name=file_name value=category>category<br>
<input type=submit value=Submit>
</form>
<%
Else
redirected_file_name=Request.Form("file_name") & ".asp"
Response.Redirect redirected_file_name
End If
%>
</body>
</html>
...but the Soon is eclipsed by the Moon
 
Old June 11th, 2003, 05:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Hmm....

Try the following:

1. On the first page you have to change action attribute to the page3.asp or whatever named
your third page.
So, <form action=page3.asp... instead of <form action=search2.asp...

2. You don't need a second page.

3. On your third page you have to insert (at the top of the page):

Code:
contractno=Request.Form("contractno")
recordno=Request.Form("recordno")
category=Request.Form("category")

ssql="SELECT * FROM archive2 where "
If contractno=="" then
    ssql=ssql & "1=1"
Else
    ssql=ssql & " contractno='" & contractno & "'"
End If

If recordno<>"" then
    ssql=ssql & " AND recordno='" & recordno & "'"
End If

If category<>"" then
    ssql=ssql & " AND category='" & category & "'"
End If
...but the Soon is eclipsed by the Moon
 
Old June 14th, 2003, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It move to contno.asp page and also display the records.
But how it move to recordno.asp and category.asp page
I want that when I select recordno option, it move to recordno.asp page And when I select category it move to category.asp page and also display records.


<html>
<HEAD>
</HEAD>
<BODY>
<form method=post action=wpls5.asp id=form name=form>
<%
contractno=Request.Form("contractno")
recordno=Request.Form("recordno")
Category=Request.Form("category")

set cn=server.CreateObject("adodb.connection")

cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"

cn.Open
ssql="select * from arc where "
If contractno="" then
     ssql=ssql & "1=1"
Else
     ssql=ssql & " contractno='"& contractno & "'"
End if
if recordno<>"" then
      ssql=ssql & " AND recordno='" & recordno & "'"
End if

If category<>"" then

ssql=ssql & " AND category ='" & category & "'"

End If


ssql="SELECT * FROM arc where contractno='" &contractno & "'"

set rs=cn.Execute(ssql)

%>

<TABLE border=1 bordercolorlight="#669999" bordercolordark="#330066">

<tr bgcolor=gold>

<th>Contract No</th>
<th>Record Drawing No</th>
<th>Description</th>
<th>Drawing Category</th>
<th>Contractor</th>
<th>Consultant</th>

<th>Drawing No</th>
<th>ImageReference</th>
<th>Window_x1</th>
<th>Window_y1</th>
<th>Window_x2</th>
<th>Window_y2</th>
</tr>
<%

do while rs.eof=false

Response.Write("<tr>")

Response.Write("<td bgcolor=lightyellow>" & rs("contractno") & "</td>")

Response.Write("<td>" & rs("recordno") & "</td>")
Response.Write("<td>" & rs("description") & "</td>")
Response.Write("<td>" & rs("category") & "</td>")
Response.Write("<td>" & rs("contractor") & "</td>")
Response.Write("<td>" & rs("consultant") & "</td>")
Response.Write("<td>" & rs("drawingno") & "</td>")
Response.Write("<td>")
Response.Write("<a href=" & server.URLEncode(rs("imagereference")) & ">" & rs("imagereference") & "</a>")
Response.Write("</td>")
Response.Write("<td>" & rs("window_x1") & "</td>")
Response.Write("<td>" & rs("window_y1") & "</td>")
Response.Write("<td>" & rs("window_x2") & "</td>")
Response.Write("<td>" & rs("window_y2") & "</td>")
Response.Write("<tr>")
rs.movenext
loop

%>

</TABLE>


<INPUT id=submit2 name=submit2 type=submit value="Back" target=Right>
</P>
<P>&nbsp;</P>
</BODY>
</HTML>

</body>
</html>

with kind regards.

Mateen Martin
[email protected]



Quote:
quote:Originally posted by NotNowJohn
 Hmm....

Try the following:

1. On the first page you have to change action attribute to the page3.asp or whatever named
your third page.
So, <form action=page3.asp... instead of <form action=search2.asp...

2. You don't need a second page.

3. On your third page you have to insert (at the top of the page):

Code:
contractno=Request.Form("contractno")
recordno=Request.Form("recordno")
category=Request.Form("category")

ssql="SELECT * FROM archive2 where "
If contractno=="" then
    ssql=ssql & "1=1"
Else
    ssql=ssql & " contractno='" & contractno & "'"
End If

If recordno<>"" then
    ssql=ssql & " AND recordno='" & recordno & "'"
End If

If category<>"" then
    ssql=ssql & " AND category='" & category & "'"
End If
...but the Soon is eclipsed by the Moon
 
Old June 15th, 2003, 05:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Well, I am sorry, but I am not sure that I am understand what do you want with these pages
Lets go to the beginning...

Can you, please, answer on each of teh following questions?

On the first page you have three select fields named
contractno, recordno and category respectively.
User can choose from none, one, two or all three select lists.
What do you want to do after each of the following events:
1. User hasn't choosen any option
2. User has choosen one option from select list named contractno.
3. User has choosen one option from select list named contractno, and
one option from select list named recordno.
4. User has choosen one option from each select list.

After user's click on Search button where you want to redirect him in each
of these scenarios?

Then, we will solve this, step by step.

Regs,
NNJ

...but the Soon is eclipsed by the Moon
 
Old June 16th, 2003, 03:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your courageous response.

1. yes I have three select option on first page.
2. yes user select one option from the select list name contractno.
3. yes it may be possible that user choosen one select option from
   contractno and one select option from recordno list.
4. yes user can select one select option for each select list.
5. yes it is better, you solve it step by step.

a. if in first option if user select any one option from the select
   list, it will redirect to that page ie contractno.asp
b. if user select contractno then it should be redirect to
   contractno.asp page and pass the contractno value.
c. if user select recordno then it should be redirect to
   recordno.asp page and pass recordno value so that on
   recordno.asp page display the records.
d. if user select category then it should be redirect to category.asp
   page with category value, so the it will display category records.
e. if user select two select option from the select list
   then it redirect to another page and also pass two select value
f. if user select three select option then it will redirect to
    another new page and as well as pass three select value
    to next page.

hence, total six (6) pages will involve this case.

 firstpage.asp, contractno.asp, recordno.asp, category.asp
  and two more pages,

Please you will send coding.

I will wait your reply.

with sincere regards.

Mateen Martin
[email protected]










Quote:
quote:Originally posted by NotNowJohn
 Well, I am sorry, but I am not sure that I am understand what do you want with these pages
Lets go to the beginning...

Can you, please, answer on each of teh following questions?

On the first page you have three select fields named
contractno, recordno and category respectively.
User can choose from none, one, two or all three select lists.
What do you want to do after each of the following events:
1. User hasn't choosen any option
2. User has choosen one option from select list named contractno.
3. User has choosen one option from select list named contractno, and
one option from select list named recordno.
4. User has choosen one option from each select list.

After user's click on Search button where you want to redirect him in each
of these scenarios?

Then, we will solve this, step by step.

Regs,
NNJ

...but the Soon is eclipsed by the Moon
 
Old June 16th, 2003, 04:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Mateen,

You don't need 6 pages - you need only one page to process the select oprions from your select page. You pull out data from arc table on each page you want to create (for each users' selection or combination) - so you have to create appropriate select statement only.
So, you have to add this on your result page you sent in teh previous posts:
Code:
contractno=Request.Form("contractno")
recordno=Request.Form("recordno")
category=Request.Form("category")

ssql="SELECT * FROM archive2 where "
If contractno=="" then
    ssql=ssql & "1=1"
Else
    ssql=ssql & " contractno='" & contractno & "'"
End If

If recordno<>"" then
    ssql=ssql & " AND recordno='" & recordno & "'"
End If

If category<>"" then
    ssql=ssql & " AND category='" & category & "'"
End If
These statements include all user choosing combinations.
Why you insist on 6 pages?

...but the Soon is eclipsed by the Moon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
Select/Option Problem TSEROOGY Javascript 2 October 4th, 2004 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.