473,569 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Chec kFlashVersion(' 7,0,0,0','Conte nt 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.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=7,0,0,0"
width="400" height="300" id="FLVPlayer" >
<param name="movie" value="FLVPlaye r_Progressive.s wf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars "
value="&MM_Comp onentVersion=1& skinName=Corona _Skin_3&streamN ame=segments/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
/>
<embed src="FLVPlayer_ Progressive.swf " width="400" height="300"
flashvars="&MM_ ComponentVersio n=1&skinName=Co rona_Skin_3&str eamName=segment s/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
quality="high" scale="noscale" name="FLVPlayer " salign="LT"
type="applicati on/x-shockwave-flash"
pluginspage="ht tp://www.macromedia. com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtensi on 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 5605
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_Chec kFlashVersion(' 7,0,0,0','Conte nt 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.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#v.. ."
width="400" height="300" id="FLVPlayer" >
<param name="movie" value="FLVPlaye r_Progressive.s wf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars "
value="&MM_Comp onentVersion=1& skinName=Corona _Skin_3&streamN ame=segments/BA*K-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
/>
<embed src="FLVPlayer_ Progressive.swf " width="400" height="300"
flashvars="&MM_ ComponentVersio n=1&skinName=Co rona_Skin_3&str eamName=segment *s/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
quality="high" scale="noscale" name="FLVPlayer " salign="LT"
type="applicati on/x-shockwave-flash"
pluginspage="ht tp://www.macromedia. com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtensi on 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,heig ht=400";
window.open(url , "newWindow" , options);

// in newWindow:
window.myVar1 = opener.var1; // opener is the window object of the
parent window
alert(window.my Var1); // 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_Chec kFlashVersion(' 7,0,0,0','Conte nt 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.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#v.. ."
width="400" height="300" id="FLVPlayer" >
<param name="movie" value="FLVPlaye r_Progressive.s wf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars "
value="&MM_Comp onentVersion=1& skinName=Corona _Skin_3&streamN ame=segments/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
/>
<embed src="FLVPlayer_ Progressive.swf " width="400" height="300"
flashvars="&MM_ ComponentVersio n=1&skinName=Co rona_Skin_3&str eamName=segment s/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
quality="high" scale="noscale" name="FLVPlayer " salign="LT"
type="applicati on/x-shockwave-flash"
pluginspage="ht tp://www.macromedia. com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtensi on 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.s ubstr(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_Chec kFlashVersion(' 7,0,0,0','Conte nt 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.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#v.. ."
width="400" height="300" id="FLVPlayer" >
<param name="movie" value="FLVPlaye r_Progressive.s wf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars "
value="&MM_Comp onentVersion=1& skinName=Corona _Skin_3&streamN ame=segments/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
/>
<embed src="FLVPlayer_ Progressive.swf " width="400" height="300"
flashvars="&MM_ ComponentVersio n=1&skinName=Co rona_Skin_3&str eamName=segment s/BAK-BandBackExtensi on&autoPlay=tru e&autoRewind=fa lse"
quality="high" scale="noscale" name="FLVPlayer " salign="LT"
type="applicati on/x-shockwave-flash"
pluginspage="ht tp://www.macromedia. com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtensi on 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
2194
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 may be pointed to different URLs depending upon the table key. The variable substitution works fine when hardcoding into the script, e.g.: ...
15
2681
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 this?
9
19901
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 MadminRS.CursorType = adOpenKeyset MadminRS.LockType = adLockOptimistic MadminRS.Open "NavBar", objConn, , , adCmdTable MadminRS.AddNew MadminRS("Url") =...
10
5516
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 using the elipse. For example, a funciton could take in 1 known type, then a variable list of other parameters: ReturnValueClass rvc =...
2
2969
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 reached. I'm posting here because there seems to be a few MVP's knocking around, and if they dont know, then it's a safe bet nobody does. I'm...
27
10098
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 string in program works ok, but, if I use string from require file I can not seem to insert string. $cccb_id is sting..... to be inserted into...
5
1805
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 function call a1,a2 is still -1 and "AAA" I want to be change as 3,"BBB" Does anybody can help me??? class Program {
7
2455
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 the REST based Facebook API - there is a simple example for its usage as shown below: def simple_web_app(request, api_key, secret_key):
3
2835
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 programmatically set, this is necessary because I may have a simple table name or a union, hence I got to pick the correct one! Unfortunately, I...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.