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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying either a single value or all values

Status
Not open for further replies.

loveday

Programmer
Sep 19, 2004
106
US
Dear experts,
I have a table structure with following attributes:

route_Name, blockNmae, blockID, route_ID

RouteID is a unique id but blockID is not.

A route_Name is associated with blockName.

This means that route_name can have one blockName or many blockNames.

So, you could have a situation like this:

Route_Name blockName
route1 blockname1
route1 blockname2
route1 blockname3
___________________________
route2 blockname1
route2 blockname2

etc

My question is, is there anyway to come up with a code that will allow a user to view one blockname, then if he or she chooses to view the next blockname, he or she can click a button that says "next block"

He or she will keep viewing all the blocknames related to a particular route_name until all the blocks related that route_name have been viewed.

Then you get a message that says:

last blockname for route_name.

You would then be prompted to continue to next route_name.

I know this is complicated, to me it is.

So any help would be greatly appreciated.

Thanks in advance
 
sql="select * from Table where Route_Name='route1'"

will give you a list of blocks in that route. from here all you have to do is Pagination. try a search in google for it...

Known is handfull, Unknown is worldfull
 
Code:
<%
[blue]dim cn, rs, blockArr
set cn = server.createObject("adodb.connection")
cn.open application("connectString")

set rs = cn.execute("SELECT blockName FROM myTable WHERE routeID = " & request("route"))

dim arrStr, x
arrStr = ""

if not rs.eof then 
   
   blockArr = rs.getRows()
   for x = 0 to uBound(getRows,2)
      arrStr = arrStr & ",'" & blockArr(0,x) & "'"
   next
   arrStr = right(arrStr, len(arrStr) - 1)
end if[/blue]
%>
<body onLoad="showBlock()">

[red]<script>
  theIndex = 0
  allBlocks = new Array(<%=arrStr%>)
  function showBlock(){
    if (allBlocks.length == theIndex){
      document.getElementById("nextRoute").style.display = "block"
      document.getElementById("nextBlock").style.display = "none"
    }
    else{
      document.getElementById("blockText").value = allBlocks[theIndex]
      if (allBlocks.length == theIndex){
        document.getElementById("nextRoute").style.display = "block"
        document.getElementById("nextBlock").style.display = "none"
      }
      else{
        document.getElementById("nextRoute").style.display = "none"
        document.getElementById("nextBlock").style.display = "block"
        theIndex++
      }
    }
  }
</script>[/red]

Current blockname: <input id="blockText"><br>
<input type=button onClick="showBlock()" value="Next Block" id="nextBlock">
<input type=button onClick="document.location='thisPage.asp?route=<%=cInt(request("route")) + 1%>" value="Next Route" id="nextRoute">

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

 
mwolf00, thanks so much for your assistance on this and I am sorry for late response.

A couple of follow-ups, please.

One, we really didn't want to enter blockname;
in other words, we have a page that contains 2 windows:

routeName | Blockname

If you click on routeName, all blocknames associated with it are displayed on the right pane under blockname.

If you click on any of the blocks, it displays the page.

What we would like to do from that point on is to have a button that allows us to click "Next block" to view next bockname.

We would continue to do so until all blocks associated with a route name are viewed.

Take for instance, that there is a routename called routeName1 and it has 5 blocknames.
We would start viewing blockname1 by clicking on blockname1 on the right pane above under blockname.

We would then click next blockname until all 5 blocknames associated with routename1 are viewed.

At this point, we can either say "next routename" or previous blockname"

Is this possible?

Also, when I click on Current blockname and click on the button, it does nothing.

I must be doing something wrong.

Thanks again for your assistance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top