How to get variable from ASP file to html file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Gustafsson

    How to get variable from ASP file to html file

    Hi

    I have a HTML-only file, and asp file that do a databasequery.

    How can I do a query in the html file, like this: DBLookup("2").
    The asp file execute the query and respond with the result. Send it back to
    the htmlfile
    and put it were the "DBLookup(" 2")" is.

    I can not have any asp code in the html page.

    I have a php file that works like this, but how can I do the same with asp??

    You can find the phpcode here:
    Price: FREE, Type: Counts clicks on links or downloads, Language: PHP, Database required: None


    // Peter


  • Evertjan.

    #2
    Re: How to get variable from ASP file to html file

    Peter Gustafsson wrote on 23 sep 2006 in
    microsoft.publi c.inetserver.as p.general:
    I have a HTML-only file, and asp file that do a databasequery.
    >
    How can I do a query in the html file, like this: DBLookup("2").
    The asp file execute the query and respond with the result. Send it
    back to the htmlfile
    and put it were the "DBLookup(" 2")" is.
    >
    I can not have any asp code in the html page.
    Why would you want to do that, Peter?

    There are lot's of ways, but the rationale of not changing the html file
    to an asp file escapes me.

    ====

    You could use clientside script.

    You could order IIS to read a .html as a asp exention.

    You could write a serverside .html file with filesysemobject .

    You could use an <iframein yourr html page havin an .asp src.

    etc.

    ====

    Using an asp file however makes it simple:

    <h1>This is the value: <% = myASpVariable %></h1>

    I have a php file that works like this, but how can I do the same with
    asp??
    >
    You can find the phpcode here:
    http://www.phpjunkyard.com/php-click-counter.php
    I do not see there what you specify, but then, I do not use php often.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Peter Gustafsson

      #3
      Re: How to get variable from ASP file to html file

      "Evertjan." <exjxw.hannivoo rt@interxnl.net skrev i meddelandet
      news:Xns98475E5 34E042eejj99@19 4.109.133.242.. .
      Peter Gustafsson wrote on 23 sep 2006 in
      microsoft.publi c.inetserver.as p.general:
      >
      >I have a HTML-only file, and asp file that do a databasequery.
      >>
      >How can I do a query in the html file, like this: DBLookup("2").
      >The asp file execute the query and respond with the result. Send it
      >back to the htmlfile
      >and put it were the "DBLookup(" 2")" is.
      >>
      >I can not have any asp code in the html page.
      Why would you want to do that, Peter?
      The webserver doesn't support ASP.

      There are lot's of ways, but the rationale of not changing the html file
      to an asp file escapes me.
      >
      You could use clientside script.
      You could order IIS to read a .html as a asp exention.
      You could write a serverside .html file with filesysemobject .
      You could use an <iframein yourr html page havin an .asp src.
      etc.
      >
      Using an asp file however makes it simple:
      >
      <h1>This is the value: <% = myASpVariable %></h1>
      I got iframe working:
      <p><font face="Verdana"> <iframe src="dlcounts.a sp?Id=2"></iframe></font></p>
      But I have no idea about the rest. and iframe doesn't look very good.
      >I have a php file that works like this, but how can I do the same with
      >asp??
      >>
      >You can find the phpcode here:
      >http://www.phpjunkyard.com/php-click-counter.php
      >
      I do not see there what you specify, but then, I do not use php often.
      There is a download link on that page.

      Why so much problem to this i ASP?? It's really simple in PHP.
      This is the htmlcode:

      <script language="Javas cript" src="http://localhost/display.php"<!-- //-->
      </script>
      I can then anywere in the html code access the php functions:

      <font face="Verdana" size=1>
      This file has been downloaded <script
      language="Javas cript">ccount_d isplay('1')</script>&nbsp;ti mes.<br>
      This file has been downloaded <script
      language="Javas cript">ccount_d isplay('2')</script>&nbsp;ti mes.<br>
      This file has been downloaded <script
      language="Javas cript">ccount_d isplay('3')</script>&nbsp;ti mes.<br>
      </font>

      // Peter


      Comment

      • Evertjan.

        #4
        Re: How to get variable from ASP file to html file

        Peter Gustafsson wrote on 23 sep 2006 in
        microsoft.publi c.inetserver.as p.general:
        "Evertjan." <exjxw.hannivoo rt@interxnl.net skrev i meddelandet
        news:Xns98475E5 34E042eejj99@19 4.109.133.242.. .
        >Peter Gustafsson wrote on 23 sep 2006 in
        >microsoft.publ ic.inetserver.a sp.general:
        [...]
        >>I can not have any asp code in the html page.
        >
        >Why would you want to do that, Peter?
        >
        The webserver doesn't support ASP.
        >
        >
        >There are lot's of ways, but the rationale of not changing the html
        >file to an asp file escapes me.
        [...]
        >
        I got iframe working:
        <p><font face="Verdana"> <iframe
        src="dlcounts.a sp?Id=2"></iframe></font></pBut I have no idea about
        the rest. and iframe doesn't look very good.
        Impossible, your site does not support ASP.

        You cannot get a asp file executed on the same server if you first
        correctly state it cannot be done.

        >>I have a php file that works like this, but how can I do the same
        >>with asp??
        >>>
        >>You can find the phpcode here:
        >>http://www.phpjunkyard.com/php-click-counter.php
        >>
        >I do not see there what you specify, but then, I do not use php
        >often.
        >
        There is a download link on that page.
        Why so much problem to this i ASP?? It's really simple in PHP.
        This is the htmlcode:
        >
        <script language="Javas cript" src="http://localhost/display.php"<!--
        //--</script>
        You can do that in asp as in php.
        There is no difference, as you can make a js code page with both.

        btw: language="Javas cript" and <!-- //--are deprecated since 10 years
        now.
        I can then anywere in the html code access the php functions:
        >
        <font face="Verdana" size=1>
        This file has been downloaded <script
        language="Javas cript">ccount_d isplay('1')</script>&nbsp;ti mes.<br>
        This file has been downloaded <script
        language="Javas cript">ccount_d isplay('2')</script>&nbsp;ti mes.<br>
        This file has been downloaded <script
        language="Javas cript">ccount_d isplay('3')</script>&nbsp;ti mes.<br>
        </font>
        These are NOT php functions, but clientside javascript functions.


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Peter Gustafsson

          #5
          Re: How to get variable from ASP file to html file

          "Evertjan." <exjxw.hannivoo rt@interxnl.net skrev i meddelandet
          news:Xns98475E5 34E042eejj99@19 4.109.133.242.. .
          These are NOT php functions, but clientside javascript functions.
          I know, I just just showed how the html code looked like.

          This is the PHP code in display.php:

          <?php
          require_once "settings.p hp";

          if($settings['system'] == 2) {$settings['newline']="\r\n";}
          elseif($setting s['system'] == 3) {$settings['newline']="\r";}
          else {$settings['newline']="\n";}

          echo "var ccount_link = new Array();\n";

          $lines = file($settings['logfile']);

          foreach ($lines as $thisline) {
          trim($thisline) ;
          list($id,$added ,$url,$count,$l inkname)=explod e("%%",$thislin e);
          echo "ccount_lin k[$id]=$count;\n";
          }
          echo "
          function ccount_display( id)
          {
          document.write( ccount_link[id]);
          }
          ";
          exit();
          ?>

          // Peter


          Comment

          • Evertjan.

            #6
            Re: How to get variable from ASP file to html file

            Peter Gustafsson wrote on 23 sep 2006 in
            microsoft.publi c.inetserver.as p.general:
            >"Evertjan." <exjxw.hannivoo rt@interxnl.net skrev i meddelandet
            >news:Xns98475E 534E042eejj99@1 94.109.133.242. ..
            >These are NOT php functions, but clientside javascript functions.
            >
            I know, I just just showed how the html code looked like.
            So the requested asp cod is on another server?
            This is the PHP code in display.php:
            >
            <?php
            require_once "settings.p hp";
            [...]
            ?>
            As far as I can see, the php just makes an js code that can be executed
            clientside and contains an array, but my php knowledge is not that good.

            Let me give you an ASP example:


            ========== myJS.asp on server1 ===========
            <%
            a = "Hello"
            b = "world"
            c = "!"
            d = session("myName ")
            %>
            var myArray = [<%=a%>,<%=b%>,< %=c%>,<%=d%>]
            =============== =============== =============


            ======= myExample.html on server2 without asp ===========
            <head>
            <script type='text/javascript' src='http:/server1.com/myJS.asp'></script>
            </head>
            <body>
            This is the text:
            "<script type='text/javascript'>
            document.write( myArray(0)+' '+myArray(1)+my Array(2))
            </script>"
            <br>
            Yours truly,
            <br>
            <script type='text/javascript'>
            document.write( myArray(3))
            </script>.


            </body>
            </html>
            =============== =============== ==============

            NOT tested.

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            • Anthony Jones

              #7
              Re: How to get variable from ASP file to html file


              "Peter Gustafsson" <sm5tri@NO_SPAM _passagen.sewro te in message
              news:eL$RZWq3GH A.4976@TK2MSFTN GP02.phx.gbl...
              Hi
              >
              I have a HTML-only file, and asp file that do a databasequery.
              >
              How can I do a query in the html file, like this: DBLookup("2").
              The asp file execute the query and respond with the result. Send it back
              to
              the htmlfile
              and put it were the "DBLookup(" 2")" is.
              >
              I can not have any asp code in the html page.
              >
              I have a php file that works like this, but how can I do the same with
              asp??
              >
              You can find the phpcode here:
              Price: FREE, Type: Counts clicks on links or downloads, Language: PHP, Database required: None

              >
              // Peter
              >
              >
              Can your HTML include Javascript? If so then perhaps the XMLHTTP object is
              what you need to make a call the to the ASP page that will do the
              DBLookup("2") for you.



              Comment

              • Peter Gustafsson

                #8
                Re: How to get variable from ASP file to html file


                "Anthony Jones" <Ant@yadayadaya da.comskrev i meddelandet
                news:eQ5IT%23y3 GHA.1292@TK2MSF TNGP03.phx.gbl. ..
                >
                "Peter Gustafsson" <sm5tri@NO_SPAM _passagen.sewro te in message
                news:eL$RZWq3GH A.4976@TK2MSFTN GP02.phx.gbl...
                >Hi
                >>
                >I have a HTML-only file, and asp file that do a databasequery.
                >>
                >How can I do a query in the html file, like this: DBLookup("2").
                >The asp file execute the query and respond with the result. Send it back
                to
                >the htmlfile
                >and put it were the "DBLookup(" 2")" is.
                >>
                >I can not have any asp code in the html page.
                >>
                >I have a php file that works like this, but how can I do the same with
                asp??
                >>
                >You can find the phpcode here:
                >http://www.phpjunkyard.com/php-click-counter.php
                >>
                >// Peter
                >>
                >>
                >
                Can your HTML include Javascript? If so then perhaps the XMLHTTP object
                is
                what you need to make a call the to the ASP page that will do the
                DBLookup("2") for you.
                Hi!

                Yes, javascript is OK to use, it's run at clientside. XMLHTTP was something
                new to me.
                But is it supported by all webbrowsers?

                Do you have any example?

                // Peter


                Comment

                • Anthony Jones

                  #9
                  Re: How to get variable from ASP file to html file


                  "Peter Gustafsson" <sm5tri@NO_SPAM _passagen.sewro te in message
                  news:Odq0RW33GH A.2228@TK2MSFTN GP03.phx.gbl...
                  >
                  "Anthony Jones" <Ant@yadayadaya da.comskrev i meddelandet
                  news:eQ5IT%23y3 GHA.1292@TK2MSF TNGP03.phx.gbl. ..

                  "Peter Gustafsson" <sm5tri@NO_SPAM _passagen.sewro te in message
                  news:eL$RZWq3GH A.4976@TK2MSFTN GP02.phx.gbl...
                  Hi
                  >
                  I have a HTML-only file, and asp file that do a databasequery.
                  >
                  How can I do a query in the html file, like this: DBLookup("2").
                  The asp file execute the query and respond with the result. Send it
                  back
                  to
                  the htmlfile
                  and put it were the "DBLookup(" 2")" is.
                  >
                  I can not have any asp code in the html page.
                  >
                  I have a php file that works like this, but how can I do the same with
                  asp??
                  >
                  You can find the phpcode here:
                  Price: FREE, Type: Counts clicks on links or downloads, Language: PHP, Database required: None

                  >
                  // Peter
                  >
                  >
                  Can your HTML include Javascript? If so then perhaps the XMLHTTP object
                  is
                  what you need to make a call the to the ASP page that will do the
                  DBLookup("2") for you.
                  >
                  Hi!
                  >
                  Yes, javascript is OK to use, it's run at clientside. XMLHTTP was
                  something
                  new to me.
                  But is it supported by all webbrowsers?
                  >
                  Do you have any example?
                  >
                  Most modern browsers support a form of the XMLHTTPRequest object, I use this
                  function which works for IE6 and FF:-

                  function getHTTP()
                  {

                  if (window.XMLHttp Request)
                  return new XMLHttpRequest( )
                  else
                  return new ActiveXObject(" MSXML2.XMLHTTP. 3.0")

                  }

                  To fetch something from ASP use:-

                  function dbLookup(value)
                  {

                  if (value == null) value = ''

                  var oXH = getHTTP()

                  oXH.Open("GET", "http://asphost.domain. com/dblookup.asp?va lue=" + value,
                  False)
                  oXH.Send()
                  if (oXH.status == 200)
                  return oXH.responseTex t
                  else
                  throw "Fetching " + value + " failed"

                  }

                  dblookup.asp

                  <!-- #include virtual="/YourCodeThatImp lementsDBLookup .asp" -->
                  <%
                  Dim Value : Value = CLng(Request.Qu eryString("valu e"))
                  Response.Write DBLooup(Value)
                  %>


                  Anthony.
                  // Peter
                  >
                  >

                  Comment

                  Working...