By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

Passing variable via include?

P: n/a
is it possible to pass a variable via a searchquery (as in after the
question mark) of an include, from an html file? Something like: ..

<script ... src="include.js?green">

... and the in the "include.js" file pick the value up:

if ( searchquery =="green"){
do something green
}

Or would it be done by some different method, if at all possible? I.e. to
set a variable from the <script src=..> level of the function call.

Jun 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Fred Lazy wrote:
is it possible to pass a variable via a searchquery (as in after the
question mark) of an include, from an html file? Something like: ..

<script ... src="include.js?green">

.. and the in the "include.js" file pick the value up:

if ( searchquery =="green"){
do something green
}

Or would it be done by some different method, if at all possible? I.e. to
set a variable from the <script src=..> level of the function call.


## first js script:
-----
<script type="text/javscript" src="include.php?green=1"></script>
-----
## server-side php script 'include.php':
-----
<?php header("Content-type: text/javascript"); ?>

var green = '<?=isset($_GET['green']) ? $_GET['green'] : 'null'?>';

if ( green == 1 ) ....
-----
Jun 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.