Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Make two response.write to clients

Hi experts, how to send two data via response.write to clients?

asp serverside:

<%
dim user, sta
user = request.querystring("q")
sta = "post"

response.expires=-1
set cn=Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "driver={SQL Server};server=MYSERVER;uid=;pwd=;database=MobileOrder"
cn.Open
'cn.Execute("Update Trxno set db_docno = db_docno +1 where code='WebTrx'")
Set rs = cn.Execute("Select messages, name from PublicNotice where status='" & sta & "' And destination='" & user & "'")        

   With rs
      If not .BOF = True And not .EOF = True Then
         ''found record
         response.write(rs("messages")) //here I want to include the "name"
         cn.Execute("Update PublicNotice set status='Read' where status='post'")
      else
         response.write("No record!")
      End If
   end with
%>
Avatar of Big Monty
Big Monty
Flag of United States of America image

you can use the following syntax, notice the <br/> i put in for readability:

response.write("messages - " & rs("messages") & "<br/>name - " & rs("name"))
Avatar of Whing Dela Cruz

ASKER

I will try it now Monty, and what about to receive? this is my code to receive,

document.getElementById("messages ").innerHTML=this.responseText;
you're mixing up client side technology (document.getElementById....) with server side technology (Response.Write....)

what EXACTLY do you want to have happen?
A message response from server is this one, as you suggested me to do response.write("messages - " & rs("messages") & "<br/>name - " & rs("name")). So there are two of them. I can be able to receive one data by using this code  document.getElementById("reTT").innerHTML=this.responseText; This is client side. My problem is how to receive the two datas like the example codes above you provided?
Hi Monty, I forgot to mention that I am using xmlhttp.send();
I'm sorry, I don't quite understand what you mean.

You would use Response.Write during the time it takes to render the page, and you would use the document.getElementById statement after the page renders and you have all of the elements to reference.

Are you trying to write back a response after using an AJAX call (xmlhttp.send())? if so, please post your code that does that, or if the page is small enough, the whole page.
Hi Monty, this is the Html codes

<!DOCTYPE html>
<html>
<body>
<form>
  <input type="hidden" id="xx" onchange="showCustomer()"/>
  <button onclick="return show()">Go</button>
</form>
<div id="reTT">reTT</div>
</body>

<script>
function showCustomer()
{
  var phn = "i100";
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (this.readyState==4 && this.status==200)
    {
    document.getElementById("reTT").innerHTML=this.responseText; //I want here to receive another data from server 
    }
  }
    xmlhttp.open("GET","getcustomer.asp?q="+phn,true);
    xmlhttp.send();
}
</script>
<script>
function show()
  {
    document.getElementById("xx").onchange();
    return false;
  }
</script>

</html>

Open in new window

css

<%
dim user, sta
user = request.querystring("q")
sta = "post"

response.expires=-1
set cn=Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "driver={SQL Server};server=MYSERVER;uid=;pwd=;database=MobileOrder"
cn.Open
Set rs = cn.Execute("Select messages, name from PublicNotice where status='" & sta & "' And destination='" & user & "'")        

   With rs
      If not .BOF = True And not .EOF = True Then
         ''found record
         response.write(rs("messages"))
      else
         response.write("No record!")
      End If
   end with

%>

Open in new window

HI Big Monty, you suggested me to use this
response.write("messages - " & rs("messages") & "<br/>name - " & rs("name"))
but it didn't work. and I can't trace what's wrong on it. Thank you!
Do you get an error?
Hi Monty, I've got an error that says: "Internal server error"
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
tested solution works for me