Avatar of Whing Dela Cruz
Whing Dela Cruz
Flag 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
%>
ASPJavaScript

Avatar of undefined
Last Comment
Big Monty

8/22/2022 - Mon
Big Monty

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

response.write("messages - " & rs("messages") & "<br/>name - " & rs("name"))
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;
Big Monty

you're mixing up client side technology (document.getElementById....) with server side technology (Response.Write....)

what EXACTLY do you want to have happen?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Whing Dela Cruz

ASKER
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?
Whing Dela Cruz

ASKER
Hi Monty, I forgot to mention that I am using xmlhttp.send();
Big Monty

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Whing Dela Cruz

ASKER
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

Whing Dela Cruz

ASKER
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

Whing Dela Cruz

ASKER
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!
Your help has saved me hundreds of hours of internet surfing.
fblack61
Big Monty

Do you get an error?
Whing Dela Cruz

ASKER
Hi Monty, I've got an error that says: "Internal server error"
ASKER CERTIFIED SOLUTION
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Big Monty

tested solution works for me
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.