473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Variable Substitution Using Query String Params - PLEASE HELP

OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,
www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip
Feb 12 '07 #1
3 5594
On Feb 11, 10:17 pm, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BA*K-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segment*s/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip
This is not a javascript answer but I think it might work for
you...you can use server-side language...I prefer PHP. In php a simple
version

URL: www.sitename.com/site.php?video=myvideoname
script for PHP
<?php //php start tag
if(isset($_GET['video']) && $_GET['video'] != "")) \\deterimines if
the URL var is set
{
?>
<object>
flash stuff...i wasn't sure where you wanted to use it.
<embed src="../<?php echo $_GET['video'];
//echo will write the contents to screen of the url var 'video'
}//end if
?>.swf" ... />
</object>

let me know if that makes sences.

Adambrz
Adambrz.com

Feb 12 '07 #2
JS' objects are extensible. The window object is a global object. So
after working on your url parameters, you may then add new variables
to the window object like:
window.var1 = "foo";
window.var2 = "bar";

these variables (object properties) are then all accessible within
this window (mind you an (i)frame is a new window). Or even better. If
you open the new window yourself, you may access the properties of the
parent window (no need for url parameters):

// main window:
window.var1 = "foo"; url = "somepage.html"; options =
"width=400,height=400";
window.open(url, "newWindow", options);

// in newWindow:
window.myVar1 = opener.var1; // opener is the window object of the
parent window
alert(window.myVar1); // should show "foo";

method 2 does only work if you (the user) opens the new window. due to
security measures js is not allowed to access properties in windows
created by other pages/served from other domains.

HTH,
Simon
On Feb 12, 5:17 am, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip

Feb 12 '07 #3
// url = www.myhome.com/mypage?video=BAK-Extension&b=2

var parameters = new Array();
// remove the "?" from the leading query string
var query = window.search.substr(1);
// query = "video=BAK-Extension&b=2"
var qParis = query.split("&"); // array with "name=value" pairs
for (i=0; i<qPairs.length; i++) {
var nv = qPairs[i].split("=");
parameters[nv[0]] = nv[1]; // mind you, you might have to unescape
}
// all passed url parameters are now in an associative array
// parameters, it should look like:
// parameters["video"] = "BAK-Extension";
// parameters["b"] = "2";
HTH
-S

PS: no tested from the top of my head ... might have typos. is JS 1.0
compatible.

On Feb 12, 5:17 am, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip


Feb 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bofh | last post by:
I'm working on a project where I need to store a CGI query in a database field. The query contains variables which will be substitued at runtime (e.g., today's date, key to select upon, etc), and...
15
by: Jay | last post by:
I'm sure this is a really dumb question, but how do you detect a variable type in Python? For example, I want to know if the variable "a" is a list of strings or a single string. How do I do...
9
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer...
10
by: Clay_Culver | last post by:
I have heard that it is possible to use classes + template magic to make standalone functions (or maybe just a functor which acts like a function) which can accept variable length arguments without...
2
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
27
by: user | last post by:
Have require file with several query stings in it. Depending on user input one of strings is selected. Everything going along smoothly until I wanted to also input a variable in string. If I put...
5
by: cty0000 | last post by:
I need to set several variable (can be different type) by sub function.. I don't know the count of variable and type, so i used object type and parameter list like below source.. After setData...
7
by: sami | last post by:
Hi I am trying to write a facebook application in python - I have been programming simple desktop applications till now and am not really familiar with web apps Pyfacebook is the wrapper for...
3
by: Andrea Raimondi | last post by:
Hello peers! I'm working on this application and I'm in need for some thoughtful advice :-p I have an SQLDataSource with params, select, etc. One of my params is the table name, which can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.