I resorted to using Google Translate, so please don't inquire why.
Currently, I'm working on a script where I am attempting to incorporate a variable (using JavaScript) into a CSS file.
<span id="s-map"></span>
{background: url('backgrounds/{<span id="s-map"></span>}/1.jpg;');}
The issue I am facing is that I am employing a background scroll and trying to utilize a variable in order to finalize the path leading to the background images /
Here's a brief explanation of the scenario:
(The script is invoked in a game via URL. The page details will be fetched from the game, hence originating the "mapname" variable)
The current map in the game is de_dolls | So mapname= "de_dolls";
function GameDetails(mapname) {
document.getElementById("s-map").innerHTML = mapname;
}
Url ('backgrounds/ {<span id="s-map"> </ span>} / 1.jpg;');}
And now I aim to achieve this result:
Url ('backgrounds/de_dolls/1.jpg;');}
I hope someone comprehends the system....
Below are all the relevant parts of the script:
Javascript.js
function GameDetails(servername, serverurl, mapname, maxplayers, steamid, gamemode) {
document.getElementById("s-name").innerHTML = servername;
document.getElementById("s-map").innerHTML = mapname;
document.getElementById("s-mode").innerHTML = gamemode;
document.getElementById("s-max").innerHTML = maxplayers;
}
index.php
<div id="background-scroll">
<div id="bg1"></div><!-- BG 1 -->
<div id="bg2"></div><!-- BG 2 -->
<div id="bg3"></div><!-- BG 3 -->
<div id="bg4"></div><!-- BG 4 -->
<div id="bg5"></div><!-- BG 5 -->
<div id="bg6"></div><!-- BG 6 -->
</div>
style.css
#background-scroll { width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index:-10;}
#bg1 {background: url('backgrounds/*MAPNAME*/1.jpg;'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
#bg2 {background: url('backgrounds/*MAPNAME*/2.jpg; ?>'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
#bg3 {background: url('backgrounds/*MAPNAME*/3.jpg; ?>'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
#bg4 {background: url('backgrounds/*MAPNAME*/4.jpg; ?>'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
#bg5 {background: url('backgrounds/*MAPNAME*/5.jpg; ?>'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
#bg6 {background: url('backgrounds/*MAPNAME*/6.jpg; ?>'); background-size: 100% auto; background-size: cover; width: 100%; height: 100%;}
Many thanks in advance! Please feel free to ask if you have any questions :)