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

writeln problem with " and '

Status
Not open for further replies.

novice2004

Programmer
Feb 2, 2004
62
US
Help please,

Can anybody look at this code:
Everything works fine when I use Line 1.
When I tried to use Line 2 instead of Line 2 I got empty page.
I am trying to use var imgSrc without success.
Path to pictures: "" ...

function openInsidePage(i) {

var imgSrc="
writeln('function nextImage() {');
writeln('if (currentPicture != totalPictures) {');
writeln('currentPicture++');

Line 1:
writeln('document.mainimage.src = " + currentPicture + ".jpg";'); //works

Line 2:
writeln('document.mainimage.src = "' + imgSrc + 'picture' + currentPicture + '.jpg";'); //does not work

Thank you
 
Try this:
Code:
var imgSrc="[green]\'[/green][URL unfurl="true"]http://www.XXX.com/PhotoAlbum/[/URL][green]\'[/green]";
 
Here is a reworked solution that I think will do what you want:

Code:
var imgSrc="[URL unfurl="true"]http://www.XXX.com/PhotoAlbum/";[/URL]
var _html = "";
_html += "function nextImage() {";
_html += "if (currentPicture != totalPictures) {";
_html += "currentPicture++";
_html += "document.mainimage.src = \"" + imgSrc + "picture" + currentPicture + ".jpg\"";
_html += "}";
_html += "}";
document.write(_html);

All the best,
Jeff
 
If this works:

writeln('document.mainimage.src = " + currentPicture + ".jpg";');

...and all you want to do is replace with imgSrc, then try:

writeln('document.mainimage.src = "'+imgSrc+'picture" + currentPicture + ".jpg";');

All I did was replace with '+imgSrc+'.

Other quotes shouldn't need changing.

'hope that helps.

--Dave
 
Bingo Dave. You got it. Thanks a lot.

Thank you very much everybody.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top