SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Assign javascript variables to ASP (VbScript)

    Hi,

    Is it possible to assign javascript variables values to ASP?

    e.g. How would I store the following JS variable as an ASP variable in VBScript?
    Code:
    <script type="text/javascript">
    var intJavaScriptNumber = 25;
    </script>
    The problem is I've got about 50 of these variables on a page, and they all need to be used in a simple equation which slows the browser down. If I could get them all into ASP then I could process this server side much more comfortably.


    Thanks for your advice...

  2. #2
    SitePoint Addict MadDog's Avatar
    Join Date
    Aug 2002
    Location
    Oregon, USA
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only way to assign a ASP variable to javascript is to write it out, like below:

    Code:
    var intJavaScriptNumber = <% = YourASPVariable %>
    Drew Gauderman
    ASP/MSSQL/AJAX-Javascript/HTML/CSS Coder
    iPortalX The most secure FREE ASP portal!

  3. #3
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think he means that he needs the JavaScript values to use in his server side script.

    Since JS works client side and VBScrip/ASP is server side, you will need to post to the server and grab them in your ASP script. on a page load, the server side script (asp/vbscript) executes first and then sends to the browser where your JavaScript executes. You will either need to set up a link and put the JS values in the querystring or do a post from your JavaScript and send them that way.

  4. #4
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Bill, yes, MadDog had it the wrong way 'round. You've given me some ideas there - didn't think about posting on the querystring and grabbing them that way.

  5. #5
    SitePoint Addict MadDog's Avatar
    Join Date
    Aug 2002
    Location
    Oregon, USA
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that, i read it a little to fast and misread it.
    Drew Gauderman
    ASP/MSSQL/AJAX-Javascript/HTML/CSS Coder
    iPortalX The most secure FREE ASP portal!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •