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

document.write issue

Status
Not open for further replies.

leahyj

MIS
May 5, 2004
107
US
Hi,

I have an ASP script that writes a javascript array (works like a charm elsewhere), but this time I am getting an error ("imgsec is not defined"), and not getting the expected results.


This is what is written by the ASP:
Code:
<script type='text/javascript' language='javascript'>imgsec [0] = new Array('8','4');
imgsec [1] = new Array('8','4');
imgsec [2] = new Array('5','B');
imgsec [3] = new Array('9','h');
</script>

This is written in the body of the page:
Code:
<script type="text/javascript" language="javascript">
document.write("<img border='1' src='/images/'" + imgsec[0][1] + ".JPG' width='50' height='50'>");
</script>

Thanks for any help.
 
Like the error message says, you haven't defined imgsec before you use it as an array. Have the ASP write this first:
Code:
var imgsec = new Array();

Lee
 
Trollacious:

Thanks, that got rid of the error.

What's weird is that I use the same array type creating elsewhere without declaring it and it doesn't give an error.

Anyway, thanks.

While I have your attention,

How do I string together(using document.write) an html image tag as in my second block of code?

Code:
<script type="text/javascript" language="javascript">
document.write("<img border='1' src='/images/'" + imgsec[0][1] + ".JPG' width='50' height='50'>");
</script>

Thanks again.

 
What's not working with the example you showed for creating the image tag? The code you have is syntactically correct.

As far as the array working in another spot that you say is implemented the same way, you'd have to show the code if you want any input on that.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top