Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2006, 10:16 PM
Authorized User
 
Join Date: Apr 2006
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default Query string to a external javascript file

Hi experts,

 When we write JavaScript in an external .js file, then in the "src" Tag, Can we pass any query string variable instead of calling Function ?
If Yes, then Can we pass different query string variables in different places in the same page depending on the situation that which Value we have to pass in the Query String . In this situation, we will have to write whole "src" tag.

Its urgent,
Regards,
Anuj
 
Old November 4th, 2006, 01:26 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

Not sure what you are trying to achieve, but rather that trying to use querystring, simply declare a public variable in the external javascript file, and then assign values to this variable from any part of your page. Just try this example below:

//CODE FOR YOUR EXTERNAL FILE (can be SimpleJS.js)

//Public variable
var strValue;

//Test function
function TestValue()
{
    alert(strValue);
}

On a test page, you can try this code:
 <script language=javascript src=SimpleJS.js type=text/javascript></script>

    <script>
        function Test1()
        {
            strValue = "Testing First";
            TestValue();
        }

        function Test2()
        {
            strValue = "Testing Second";
            TestValue();
        }

    </script>
  </head>
  <body>

    <form id="TestJS" method="post" runat="server">
    <input type=button value=First onclick=Test1()><br>
    <input type=button value=Second onclick=Test2()>
     </form>

  </body>

Do let me know if you need more clarification or I have diverted from your query.

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign label or string to external html file Gin262 ASP.NET 2.0 Basics 2 May 30th, 2007 06:39 AM
External JavaScript with XSL NEO1976 XSLT 2 September 5th, 2006 07:19 AM
external CSS in JavaScript code webdesign Javascript 1 September 1st, 2006 04:35 PM
External Javascript to determine Navigation fs22 Javascript How-To 3 May 21st, 2004 03:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.