Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass var to external script

Status
Not open for further replies.

adamroof

Programmer
Nov 5, 2003
1,107
US
Hi all,

im playing around with dynamicicity of an old calendar script and works dandy. On different sites im using it on, im noticing i need to move the div to the left or right of the textbox. I do this by using (x + 151) + "px" in the script.

I would like to pass that value (151) to the script from the html, so i can just link the script and enter the adjustment values. 151 is just an arbitrary integer that worked for one site to adjust positioning.

So the question is how can i pass that variable?
Code:
<script src="js/CalendarControl.js" type="text/javascript"></script>

can i do this?
Code:
<script src="js/CalendarControl.js" type="text/javascript">
    externalVar = 151;
</script>

My attempts were thwarted by errors. I wonder about this concept because of the way old school Google Analytics urchin passes the account number

Code:
<script src="[URL unfurl="true"]http://www.google-analytics.com/urchin.js"[/URL] type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-999999-9";
urchinTracker();
</script>
 
Ok, sometimes all it takes is to ask a question to answer your own question. The below works, and since in the script i set a default value, if it is not included it will still work!

Code:
            <script src="js/CalendarControl.js" type="text/javascript"></script>
            <script type="text/javascript">
                 externalVar = 1;
            </script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top