Asp to Javascript

Asked By vinayaga moorthi A
09-Feb-10 08:33 AM
Earn up to 0 extra points for answering this tough question.
  hai

       Still i'm working in asp. My Requirment is i call one javascript, in that javascript i call one more asp.page. in that asp page only contain tha database operation. i select the pariticular value from database, now i want display that value in javascript. PlzHelpme


My Code IS: JavaScript

function hono()
{
  var cid;
  var str_xml="already Exists";
  var str_code1 = document.getElementsByName('customerid')[0].value;
     var str_url1='/karomi/custom/repco-los/search/asp/sample.asp?'+gvar_session_string+'&str_code1='+str_code1;
  //var Jvar = '<%=Str_xml%>'
  //alert(Jvar);
 

          alert('<%=Str_xml%>');
 alert("welcome");

}


And My Asp Code Is:

<%
Dim Str_cid;
Dim Str_res;
Dim Str_xml;
Dim Str_xml1;
Dim x;
Dim obj_xml;
Dim db_name;
Dim rs;
Str_cid=Request.QueryString("str_code1")  // geting from javascript
Response.write(Str_cid)
set obj_con=server.CreateObject("ADODB.Connection")
  
   obj_con.ConnectionTimeout=Gvar_Conntimeout
      db_name ="Provider = SQLOLEDB;User ID=sa;password=theme;Initial Catalog=repos;Data Source=wserver"
   set rs=Server.CreateObject("ADODB.recordset")
   rs.Open "Select customerid from f_hpf_v1 WHERE customerid = '"& Str_cid &"' ", obj_con
           for each x in rs.Fields
             Str_res=x.value
    If Str_res=Str_cid
                Str_xml="UserAlready Exists"
    'Response.Write(Str_xml)
   Else
                Str_xml="New User"  
    'Response.Write(Str_xml)
   End If
     Next
                rs.close
    obj_con.close
              

    'Response.Write(Str_xml)

%>



Thanks

  re: Asp to Javascript

Sagar P replied to vinayaga moorthi A
09-Feb-10 09:08 AM
Try double qoutes instead of single like;

alert("<%=Str_xml%>");

OR

var v1="<%=Str_xml%>";

alert(v1);


  re: Asp to Javascript

F Cali replied to vinayaga moorthi A
09-Feb-10 09:10 AM
One way to do it is to load your second asp page in an iframe that's hidden.  Then you can get the innerHTML of that iframe to get the value returned by the page:

function hono()
{
  var cid;
  var str_xml="already Exists";
  var str_code1 = document.getElementsByName('customerid')[0].value;
     var str_url1='/karomi/custom/repco-los/search/asp/sample.asp?'+gvar_session_string+'&str_code1='+str_code1;
 
    document.getElementById("otherPage").src = str_url1;
    alert(document.getElementById("otherPage").innerHTML);

 alert("welcome");

}

<iframe name="otherPage" id="otherPage" width="0" height="0" frameborder="0">

Regards,
SQL Server Helper

  re: Asp to Javascript

Frinavale Soldevi replied to vinayaga moorthi A
09-Feb-10 09:43 AM
Str_xml has been declared but no scope modifier has been used to specify how the variable can be used.

Instead of declaring Str_xml like this:
Dim Str_xml

Try using Public instead (Protected will probably work too) ...like this:
Public Str_xml

Now you should be able to access it properly in your JavaScript function:

function hono()
{
  var cid;
  var str_xml="already Exists";
  var str_code1 = document.getElementsByName('customerid')[0].value;

//The following line might be causing you problems too. I don't see where you've declared gvar_session_string....
  var str_url1='/karomi/custom/repco-los/search/asp/sample.asp?'+gvar_session_string+'&str_code1='+str_code1;

  alert('<%=Str_xml%>');
  alert("welcome");

}

-Frinny

  re: re: Asp to Javascript
vinayagq replied to Frinavale Soldevi
20-Mar-10 05:16 AM
Hai
   i try to send email using the vbscript .It say error
ActiveX component can't create object 'CDO.Message'
MyCode IS

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "thivinayagam@gamil.com"
objMessage.To = "moorthi@themetechnologies.com"
objMessage.TextBody = "This is some sample message text."

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
A

Create New Account