If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How can I connect the client with server scripts?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-06, 07:03
NonLinear NonLinear is offline
Registered User
 
Join Date: Feb 2004
Posts: 97
How can I connect the client with server scripts?

Hi, I am stuck to a very strange problem. I have a .js (javascript) file with some code inside. The file is called from an html file and executed. The result is an inline frame (<iframe>) with some vertical scrolling messages (you know...those that are used to appear news). Inside the file there are the messages in string variables.The javascript code is executed by the client (IE etc.). Ok. The problem is that I do not want every time I need to change the mesages to open the file, change the appropriate sections and upload the updated file. Is there any method to use ASP (or anything else method) to retrieve the text mesages from a database?How can I pass data that come from server side scripting to the client javascript code?
Reply With Quote
  #2 (permalink)  
Old 04-20-06, 17:29
csamuels csamuels is offline
Registered User
 
Join Date: Mar 2006
Location: south jersey, usa
Posts: 53
Quote:
Originally Posted by NonLinear
Is there any method to use ASP (or anything else method) to retrieve the text mesages from a database?
open a ado connection to the db, run a query, write the query output

this code takes a 4 digit input and returns four names.
Code:
<html>
<body OnLoad="document.getcode.agentcode.focus();">

<%
dim agentcode, puw, cuw, query, rs, conn, routepath, routefile, routename
dim tries, sqlconn, prt, crt

routepath = "c:\tasks\"
routename = "actagt2.mdb"
routefile = routepath & routename

if request.querystring("agentcode") = "" then
  agentcode = "n/a"
else
  if len(request.querystring("agentcode")) = 4 and isnumeric(request.querystring("agentcode")) then
    agentcode = request.querystring("agentcode")
  else 
    agentcode = "n/a"
    response.write "<font color=red><b>Agent Code must be a four digit number</b></font><br>"
   end if  
end if


set conn = CreateObject("ADODB.Connection")
set sqlconn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")

tries = 0
do
  conn.open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
            "DBQ=" & RouteFile & ";DefaultDir=;UID=;PWD=;"
  tries = tries + 1
Loop While (Err.Number<>0) And tries < 10

sqlconn.open "PROVIDER=SQLOLEDB;DATA SOURCE=imagergt;UID=sa;PWD=xxx;DATABASE=ImgRight"

query = "Select ENDT from MYTABLE where AGENT = '" & agentcode & "01'"
rs.open query, conn
if rs.eof then
  if not agentcode = "n/a" then
    response.write "<font color=red><b>Agent Code not found</b></font><br>"
  end if
  puw = "none found"
  prt = puw
  rs.close
else
  puw = rs(0).value
  rs.close
  query = "Select ENDT from MYTABLE where AGENT = '" & PUW & "'"
  'response.write query
  rs.open query, conn
  if rs.eof then
    prt = "none found"
    rs.close
  else
    prt = rs(0).value
    rs.close
    query = "select username from irsysusers where adjid = '" & prt & "'"
    rs.open query, sqlconn
    prt = rs(0).value
    rs.close
  end if
  query = "select username from irsysusers where adjid = '" & puw & "'"
  rs.open query, sqlconn
  puw = rs(0).value
  rs.close
end if

query = "Select ENDT from MYTABLE where AGENT = '" & agentcode & "12'"
rs.open query, conn
if rs.eof then
  cuw = "none found"
  crt = cuw
  rs.close
else
  cuw = rs(0).value
  rs.close
  query = "Select ENDT from MYTABLE where AGENT = '" & CUW & "'"
  rs.open query, conn
  if rs.eof then
    crt = "none found"
    rs.close
  else
    crt = rs(0).value
    rs.close
    query = "select username from irsysusers where adjid = '" & crt & "'"
    rs.open query, sqlconn
    crt = rs(0).value
    rs.close
    end if
  query = "select username from irsysusers where adjid = '" & cuw & "'"
  rs.open query, sqlconn
  cuw = rs(0).value
  rs.close
end if

sqlconn.close
conn.close

response.write "Agent Code - " & agentcode & "<br>Personal UW - " & puw & "<br>Commerical UW - " & cuw 
response.write "<br><BR> Personal Rater - " & prt & "<br> Commerical Rater - " & crt %>
<br><br>
<form action=" <%= request.servervariables("URL") %>" method="get" name="getcode">
Enter Agent Code:<br>
<input type="text" name="agentcode">
<input type="submit" value="Get UWs & Raters">
</form>
</body>
</html>
Quote:
How can I pass data that come from server side scripting to the client javascript code?
use response.write in server code to write the output that the client receives.

this code would create a dynamic drop down list

Code:
function getuwlist
  query = "Select uw, uwadj from underwriters order by uwadj"
  rs.open query, conn
  if rs.eof then
    getuwlist = "<option>NO UWS FOUND</option>"
    exit function
  else
    do until rs.eof
      getuwlist = getuwlist & "<option>" & rs.fields("uwadj").value & "-" & rs.fields("uw").value & "</option>"
      rs.movenext
    loop
    getuwlist = getuwlist & "</select>"
  end if    
end function
__________________
"They say Moses split the Red Sea
I split the blunt and rolled the fat one, I'm deadly"
-- Tupac 'Blasphemy'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On