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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables

Status
Not open for further replies.

rah222

Programmer
Oct 13, 2002
3
AU
Hi there.

I was wondering if anyone could help me with the use of variables in scripting.

As an example, I have some images I have created which I am using in <a href ...></a>, but until I've finished designing things I won't know how many buttons there'll be or how big I'll want them. Therefore I want the ability to change the width and height values of the image in my HTML file without having to change them here, there and everywhere as I do know.

I've tried:

height_of_button = 31
width_of_button = 118

within <script language=&quot;javascript&quot;></script>

but when I attempt

<img src ... height = height_of_button>

or

<img src ... height = &height_of_button>

the image doesn't even get rendered.

Can somebody please tell me how I use variables both:

(1) within the given HTML file
(2) globally amongst various HTML files linked together as a site

Thank you very much.

Russ.













 
vars.js content :

var height = 31;
var width = 118;


so then u can do :


<html>
<head>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;vars.js&quot;></script>
</head>
<body>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--
document.write('<img src=&quot;whatever.jpg&quot; height=&quot;' + height + '&quot; width=&quot;' + width + '&quot;>');
//-->
</script>
</body>
</html>
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top