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

Hi! Can you dynamically display information...

Status
Not open for further replies.

kaeb

Programmer
Mar 19, 2003
8
CA
from a database table in an ASP webpage using both vbscript and javascript and no backend vb6 components?

so far this is my code:

<%@ Language=&quot;VBScript&quot;%>

<%

Dim adoCn
Dim adoRcd

Set adoCn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set adoRcd = Server.CreateObject(&quot;ADODB.Recordset&quot;)

adoCn.Provider = &quot;Microsoft.Jet.OLEDB.4.0&quot;

adoCn.ConnectionString = Server.mappath(&quot;backend.mdb&quot;)

adoCn.Open

adoRcd.Open &quot;SELECT Tech_Definitions.word_id, Tech_Definitions.word, Tech_Definitions.Definition FROM Tech_Definitions&quot; , adoCn
%>

and it is displayed here:

<table border=&quot;2&quot; width=&quot;100%&quot;>
<tr>
<td width=&quot;20%&quot; valign=&quot;bottom&quot; align=&quot;center&quot;><font face=&quot;Arial&quot; size=&quot;-1&quot; color=&quot;#000000&quot;><b><%=adoRcd(&quot;Word&quot;)%></b></td>
</tr>
<tr>
<td align=&quot;center&quot;><font face=&quot;Arial&quot; size=&quot;-2&quot; color=&quot;#000000&quot;><b><%=adoRcd(&quot;Definition&quot;)%></font></td>
</tr>
</table>

I would like to create an onmousemove (not a must) function that will change the words and definitions in the same table space.

Can this be done?
Thanks for your help ;)
kaeb
 
do u mean the SQL query has to change on mouseover?
 
The simple answer is No. You cannot query the database without using server-side components. Client-side scripts do not have access to database drivers or objects that would know what to do with them if it did have drivers. Therefore you must use Server-side components to query the databases for data.

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
A direct query to the db has already been done using VBscript and the information is held in the Recordset...maybe not in a table format on an asp, but if you can rotaing graphics, why can't there be some sort of looping text? Maybe using a form element, like a text area? I am actually looking into this and if I find more info I will post it. But there should be a work around.
 
My above post is a little messy...sorry. This is what I mean to say:

A direct query to the db has already been done using VBscript and the information is held in the Recordset
Maybe I can not use a table to show the information change on the page, but if you can have rotating graphics (ASP Ad Rotator for example), why can't there be some sort of looping text? Maybe using a form element, like a text area to display the changing info?

I am still trying to find a way and absolutely rule out that it can't be done, there should be a work around.
 
I don't think you need to go as far as the functionality for the ad rotator. You could simply write the data out inot a javascript array and then havea function that is called in onLoad that uses setTimeout to change the value of the textarea to the next entry in the array. for example:
Code:
<%
'pretend we have an rs and we want to show fields title and description as one string

Response.Write &quot;var descArray = new Array(&quot; & rs.RecordCount & &quot;);&quot;

Dim ctr
Do Until rs.EOF
   Response.Write  &quot;descArray[&quot; & ctr & &quot;] = &quot;&quot;&quot; & rs(&quot;title&quot;) & &quot; - &quot; & rs(&quot;desc&quot;) & &quot;&quot;&quot;&quot;
   rs.MoveNext
   ctr = ctr + 1
Loop

%>
var globaCount = 0;
function switchText(){
   //change the displayed value to the current array value
   document.myElement.value = descArray(globalCount);
   //increment the count, make sure it loops back to 0 when it gets to the number we have in the array
   globalCount = (globalCount++)%<%=rs.RecordCount%>

   //set up the next switch for 5 seconds
   setTimeout(&quot;switchText()&quot;,5);
}
<%
'...later on...
%>
<!-- This will load the first array entry as soon as the page loads -->
<body onLoad=&quot;switchText();&quot;>

And then of course you need a text box somewhere called myElement. This code is not 100% perfect, I wrote it only as an example to show the concept, hope it helps,

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
You are such a smart cookie! Thanks Tarwn...I will try this tonight and see if I can tweak your code to get it to work. When I am done, I will post my results and even send you the url to my web page so you can see your contributions.

will keep you posted ;0)

kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top