PDA

View Full Version : Help change path to load images (hangman script)



robaldo
10-07-2016, 03:59 PM
Hi there,
a dumb question with "eval" function. I found inside script "hangman II" this line:


wrong_guesses += 1;
eval("document.hm.src=\"hm" + wrong_guesses + ".gif\"");

That shows the gif images url-of-the-page-where-script-is-displayed/hm1.gif
or
url-of-the-page-where-script-is-displayed/hm2.gif
or
url-of-the-page-where-script-is-displayed/hm3.gif
etc.

If the script (js + images) is installed in another directory (on the same domain) how can I change that line to be something like
url-of-directory-where-are-stored-js-and-images/hm1.gif
or
url-of-directory-where-are-stored-js-and-images/hm2.gif
etc?

Thank you in advance!

jscheuer1
10-07-2016, 04:17 PM
First of all eval is unnecessary. This is the same thing:


document.hm.src = 'hm' + wrong_guesses + '.gif';

And if you want to change it to use a folder or path:


document.hm.src = 'url-of-directory-where-are-stored-js-and-images/hm' + wrong_guesses + '.gif';