Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>error someone help please

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=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/\"";
var bdis = "\"><img src=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/\"";
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=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/\"";
var bdis = "\"><img src=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/\"";
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=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/\"";
var bdis = "\"><img src=http://www.codingforums.com/archive/index.php/\"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


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

window.open - cannot open with scrollbars
.js file
Help with a color fader, not going fast enough!
color name selector
?'s About JavaScript cart
Help with a simple script...
Grabbing a DOM for use with Google Maps
How can I create a stacked list of thumbnails, each one expanding with more info?

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics