Solved

Navigation with 'movenext' and Graphic-Buttons

Posted on 2004-10-07
18
271 Views
Last Modified: 2010-07-27
Dear eXperts
I reading items from a normal db

....
strSqlStmt = "SELECT * FROM praeparate WHERE unterbegriff_ger='" & produktserie & "' AND publish = 'yes'"
etc.
....

and would like to navigate with the following 'rollover buttons' to the previous and next record using the 'rs.movenext and rs.moveback' options.

    <a href="previous_page.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image121','','images/back_dark.gif',1)">
    <img src="images/back_clear.gif"    alt="Previous" name="Image121" width="56" height="43" border="0" align="absmiddle" id="Image121"></a>
    <% =view_anzeige %><% =id %><% =view_von %><% =endzahl %>
       <a href="next_page.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image111','','images/forward_dark.gif',1)">
    <img src="images/forward_clear.gif" alt="Next" name="Image111" width="56" height="43" border="0" align="absmiddle" id="Image111"></a>

Thanks * B Rgds from Spain
Manfred
0
Comment
Question by:cosmopolita
  • 9
  • 9
18 Comments
 
LVL 19

Expert Comment

by:peh803
ID: 12251457
okay, so what are you looking for?

Do you currently have a page that displays results from the "praeparate" table?  
How are you currently building that page?

peh803
0
 

Author Comment

by:cosmopolita
ID: 12251809
I have a page but I don't know how to make
the navigation buttons
http://gehwol-espana.com/view_products.asp

The page should stop just before the at the first <hr>
where the blue buttons are and wait for inputs (next or previous).

The rest are results from the
  if rs2.eof then
  response.write "<option value="""">Keine Gattungen in der Datenbank"
  else
  do until rs2.eof
 +++ here details are shown +++
  rs2.movenext
  loop
end if
0
 
LVL 19

Expert Comment

by:peh803
ID: 12251902
okay, well the first thing is this:

How do you determine which record to display on your page?  I can see that you're displaying all of them right now, but eventually, you only want one per page, right?

So you'll have to do something like this:
<%

response.write "<a href=""view_products.asp?id=122"">click to view product 122</a>"
response.write "<a href=""view_products.asp?id=123"">click to view product 123</a>"

%>

etc.

Then, when you populate your rs2 recordset, you're probably doing something like this:
rs2.open SQL_Statement, connection

Instead of doing "SELECT * FROM Table" in your SQL Statement, it would be "SELECT * FROM Table WHERE ID="&request("id")

Now, you'd open the recordset for just that one record and your page would write the 1 record only.  

If you are currently viewing record #122, your previous and next buttons would look something like this:

<%
response.write "<a href=""view_products.asp?id=121"">previous</a>"
response.write "<a href=""view_products.asp?id=123"">next</a>"
%>

Regards,
peh803
0
 

Author Comment

by:cosmopolita
ID: 12252137
Yeah, but I would like to use the
rs.movenext .and. rs.moveback (if it's right) options.

There are some 100 items in the table now.
With the above:
strSqlStmt = "SELECT * FROM praeparate WHERE unterbegriff_ger='" & produktserie & "' AND publish = 'yes'"

22 are selected.

Bow, I would like to navigate between these 22
Your otion
<%
response.write "<a href=""view_products.asp?id=121"">previous</a>"
response.write "<a href=""view_products.asp?id=123"">next</a>"
%>
is not possible as the next item may not be one of the selected ones.
0
 
LVL 19

Expert Comment

by:peh803
ID: 12252209
I understand this, but the problem is that you cannot access a server side recordset on the client.  That is, you have to repopulate your recordset before you do rs.movenext and rs.moveback, which means that you'd be at the beginning of the recordset.  

There are ways to handle the fact that the records aren't necessarily right next to each other (I can help you with SQL syntax to get previous and next ID's).  But, I'm afraid in order to move to the next item, you can't use a server side recordset.

peh803
0
 

Author Comment

by:cosmopolita
ID: 12252664
What about making a 'temp' table,
copy all the selected records there and
go from there ?
0
 
LVL 19

Expert Comment

by:peh803
ID: 12252704
ugh -- no need for a temp table when you can do it all without a temp table...

All you need is:

1.) a SQL Statement to get your records
2.) a SQL Statement to get the previous record in your recordset based on the current ID
3.) a SQL Statement to get the next record in your recordset based on the current ID

peh803
0
 

Author Comment

by:cosmopolita
ID: 12253169
Okay BUT:
Let's say we have a tabke with the following records:
1 cars
2 bikes
3 cars
4 bikes
5 cars
and I only want to navigate (show) the cars.

Going to "next" would mean I go from 1 (cars) to 2 (bikes)

Not possible ?
0
 
LVL 19

Expert Comment

by:peh803
ID: 12253329
if you only want to show cars, you have to have some way of specifying this in your select statement that gets the records out of your table!

And then, you'd have some rule that would say "Hey, if I only have 1 record in the recordset, I don't generate previous and next buttons that work."

Make sense?
peh803
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:cosmopolita
ID: 12253463
Ref.:
==
if you only want to show cars, you have to have some way of specifying this in your select statement that gets the records out of your table!

I know and that's done.
So, how van I navigate in between the cars back and forward ?
--------------------------------------------------------------------------
Ref.:
==
And then, you'd have some rule that would say "Hey, if I only have 1 record in the recordset, I don't generate previous and next buttons that work."

I know, but this comes later
0
 

Author Comment

by:cosmopolita
ID: 12257696
Dear peh803
I packed all items in different tables

Now, how to navigate
If I write:
strSqlStmt = "SELECT * FROM cars WHERE publish = 'yes' "
...
...
response.write "Car: " & rs("cars")

it only shows me the last one.

If possible pls give me the full lot.

Thanks + B Rgds
Manfred
0
 
LVL 19

Expert Comment

by:peh803
ID: 12258554
Manfred:

Please post your table structure for the Cars table.  I should be able to provide a good example for you.

Thanks,
peh803
0
 

Author Comment

by:cosmopolita
ID: 12259825
I got it so far "I THINK" - Hold on :-))
0
 
LVL 19

Expert Comment

by:peh803
ID: 12259894
ok, good!  I'll hold on as long as you like.. :)
0
 

Author Comment

by:cosmopolita
ID: 12293230
Sorry, I was late ...............
Was going to pay but if possible tell me:
When I make a query as follows:
SELECT ID, produktname_ger, text1_ger, text1_spa, text1_eng FROM pflegecremes WHERE (text1_ger LIKE '%kennedy%' ) or (text1_eng LIKE '%kennedy%' ) or (text1_spa LIKE '%kennedy%' )
it works.
And as soon as I make a UNION
SELECT ID, produktname_ger, text1_ger, text1_spa, text1_eng FROM pflegecremes UNION select ID, produktname_ger, text1_ger, text1_spa, text1_eng FROM gerlachpraeparate WHERE (text1_ger LIKE '%kennedy%' ) or (text1_eng LIKE '%kennedy%' ) or (text1_spa LIKE '%kennedy%' )
it shows me ALL records, even looking for a non existing search word like "Kennedy".
0
 
LVL 19

Accepted Solution

by:
peh803 earned 200 total points
ID: 12298021
When you run this statement:

  SELECT
    ID,
    produktname_ger,
    text1_ger,
    text1_spa,
    text1_eng
  FROM
    pflegecremes  
    UNION
  select
    ID,
    produktname_ger,
    text1_ger,
    text1_spa,
    text1_eng
  FROM
    gerlachpraeparate
  WHERE
    (text1_ger LIKE '%kennedy%' ) or
    (text1_eng LIKE '%kennedy%' ) or
    (text1_spa LIKE '%kennedy%' )

this will select ALL records from pflegecremes and it will union these records with ONLY records in gerlachpraeparate where your criteria is met in your second statement.  If you want criteria to apply to both statements, you have to specify it in both places.  Like this:

  SELECT
    ID,
    produktname_ger,
    text1_ger,
    text1_spa,
    text1_eng
  FROM
    pflegecremes  
  WHERE
    (text1_ger LIKE '%kennedy%' ) or
    (text1_eng LIKE '%kennedy%' ) or
    (text1_spa LIKE '%kennedy%' )
    UNION
  select
    ID,
    produktname_ger,
    text1_ger,
    text1_spa,
    text1_eng
  FROM
    gerlachpraeparate
  WHERE
    (text1_ger LIKE '%kennedy%' ) or
    (text1_eng LIKE '%kennedy%' ) or
    (text1_spa LIKE '%kennedy%' )

Hope this helps!
0
 

Author Comment

by:cosmopolita
ID: 12301225
You are an angel :-))
B Rgds from the Costa del Sol (Spain)
Manfred
0
 
LVL 19

Expert Comment

by:peh803
ID: 12301253
:-) glad to help!

peh803
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now