Well I don't know C, but I can give you a simple example in PHP:
PHP Code:
<?
$color = "red";
echo ("alert('" . $color . "');");
?>
So there I define a $color variable, and write into a javascript alert - I'm creating that javascript as though it were just writing a string, which as far as PHP is concerned, it is; but by the time it gets to the client, it looks like this:
With that PHP code in a file called "myscript.php" you can just include it like normal javascript
:
<script type="text/javascript" src="myscript.php"></script>
The only real caveat is that if you compile a javascript include on the server like this, the file won't have access to the document environment variables - so you can't make its data conditional on things like the document URL or referrer; however it will have access to server environment variables - session information, other data sources, and so on.
Yes?