...

View Full Version : error someone help please



bigredkacy
10-13-2005, 01:27 AM
im trrying to get this random image with link to work
but i get this error "untermenated string constant"


<script language="javascript">
<!--

var b1dis = "<a href=\"";
var bdis = "\"><img src=\"";
var edis = " width=\"100\" height=\"100\" alt=\"some text\" border=\"0\"></a>";
var rnumb = "";
var img = "";

rnumb += Math.floor(Math.random()*3);
img = rnumb;
if (img == "0") {
document.write(b1dis+ "page1.html" +bdis+ "/1.gif"" +edis);
}
if (img == "1") {
document.write(b1dis+ "page2.html" +bdis+ "/1.gif"" +edis);
}
if (img == "2") {
document.write(b1dis+ "page3.html" +bdis+ "/1.gif"" +edis);
}
// -->
</script>

TheShaner
10-13-2005, 01:50 AM
Corrections made in red. The "unterminated string constant" error was due to the missing backslashes that are in red.


<script language="javascript">
<!--

var b1dis = "<a href=\"";
var bdis = "\"><img src=\"";
var edis = " width=\"100\" height=\"100\" alt=\"some text\" border=\"0\"></a>";
var rnumb;

rnumb += Math.floor(Math.random()*3);

if (rnumb == 0) {
document.write(b1dis+ "page1.html" +bdis+ "/1.gif\"" +edis);
}
if (rnumb == 1) {
document.write(b1dis+ "page2.html" +bdis+ "/1.gif\"" +edis);
}
if (rnumb == 2) {
document.write(b1dis+ "page3.html" +bdis+ "/1.gif\"" +edis);
}
// -->
</script>

-Shane

bigredkacy
10-13-2005, 02:35 AM
i still get the same error



<script language="javascript">
<!--

var b1dis = "<a href=\"";
var bdis = "\"><img src=\"http://integy.automated-shops.com/";
var edis = " width=\"100\" height=\"100\" border=\"0\"></a>";
var rnumb;

rnumb += Math.floor(Math.random()*3);

if (rnumb == 0) {
document.write(b1dis+ "page1.html" +bdis+ "/1.gif"" +edis);
}
if (rnumb == 1) {
document.write(b1dis+ "page2.html" +bdis+ "/1.gif"" +edis);
}
if (rnumb == 2) {
document.write(b1dis+ "page3.html" +bdis+ "/1.gif"" +edis);
}
// -->
</script>

TheShaner
10-13-2005, 03:19 AM
That's because you didn't include the red backslashes that I put in there.

document.write(b1dis+ "page1.html" +bdis+ "/1.gif\"" +edis)

Don't forget the two others.

-Shane



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum