• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to assign dynamic value to <param > tage

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to pass a dynamic value to a object in a HTML, which is something like:

<html lang="en">
<head>
...
<SCRIPT language='JavaScript' charset='utf-8'> <!--
function setInit{
...
var init = 12345;
...
}
// --> </SCRIPT>
</head>
...

<object id="myObj" type="...." ....>
<param name='myVars' value='initVar="+init+"'; />
</object>
...

</html>

The init value 12345 was not passed, in stead " init " was passed. What did I do wrong?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Matt,

You can use body onload attribute to load the value.
You can refer the following piece of code.

<html>
<head>
<script>
var paramValue = 1234;
function setTextBoxValue(){
document.getElementById("textBox1").value=paramValue;
}
</script>
</head>
<body onload="setTextBoxValue()">
<input type="text" id="textBox1"/>


</body>
</html>

Regards
Valli
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You really should be doing it with a serverside language if it requires no input from the user or the browser.

you probably want to use DOM methods or document.write.

Eric
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original data is Form input and a Javascript is called with a onclick event to process the input. The init variable is a result of processing.

Eric, Could you help me with this?
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, Valli:

I tried the code below:

<!-- saved from url=(0014)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Portfolio</title>
<SCRIPT language='JavaScript' charset='utf-8'> <!--

function callInit() {
var paramElement = document.createElement("param");
paramElement.setAttribute("id", "flash");
paramElement.setAttribute("name", "flashVars");
paramElement.setAttribute("value", "quoteShare=JAVA:3322"); //hard coded value for testing

var objElement = document.getElementById("myPortfolio");
objElement.appendChild(paramElement);

var children = objElement.childNodes;
for (k=0; k<children.length; k++) {
alert(k+"=> id:"+children[k].id+"; name:"+children[k].name+"; value:"+children[k].value+"; tagName:"+children[k].tagName);
}

//I did see the <param id='flash' ...> was added under <object>. The loop shows 6 children. Three of them are "undefined". I'm not sure where are they from

objElement.loadQuotes();
}
// --> </SCRIPT>
</head>

<body scroll="yes">

<table>
<tr>
<td>
<div style="width:192px;height:310px;border:1px solid rgb(0, 0, 0);">
<table border="0">
<tr>
<td >
You may enter your own symbol and shares with correct format (e.g., IBM:100)
</td>
</tr>
<tr>
<td >
<textarea id="quoteShare" style="width:186px;font-weight:bold;font-size:11px;" rows="13" >
YHOO:200
JAVA:123
</textarea>
</td>
</tr>
<tr>
<td>
<button onclick="callInit()" type="button" style="color:#242F6D;font-weight:bold;font-size:10px;">Get Values of My Portfolio</button>
</td>
</tr>
</table>
</div>
<td>
<td>
<table border="0" >
<tr >
<td >
<object id="myPortfolio" type="application/x-shockwave-flash" data="MyPortfolio.swf" WIDTH="850" HEIGHT="460" >
<param id='param1' name='movie' value='MyPortfolio.swf'/>
<embed id='embed1' name='myPortfolio' src='MyPortfolio.swf' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='460' width='850'/>
</object>
</td>
</tr>
</table>
<td>
</tr>
</table>
</body>
</html>


The variable "quoteShare" was not passed to the swf object.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It probably did not change since it is not reading the value after you change it. Sounds like you need to use createElement or innerHTML and replace the object tag on the page when you have the info.

Eric
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried something like:

function callInit() {
var paramElement = document.createElement("param");
paramElement.setAttribute("id", "flash");
paramElement.setAttribute("name", "flashVars");
paramElement.setAttribute("value", "quoteShare=JAVA:3322");;

var objElement = document.getElementById("myPortfolio");
objElement.appendChild(paramElement);

var myElement = document.getElementById("flash");
alert(myElement.value); //It shows the value correctly
}

...

<object id="myPortfolio" type="application/x-shockwave-flash" data="MyPortfolio.swf" WIDTH="850" HEIGHT="460" >
<param name='movie' value='MyPortfolio.swf'/>
<embed name='myPortfolio' src='MyPortfolio.swf' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='460' width='850'/>
</object>

The swf object was called, but the param "flashVars" was not passed with the call.
If I just add the element <param name='flashVars' value='quoteShare=JAVA:123' /> within <object>, the 'flashVars' variable will be passed.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did some more testing on the <object > of swf and <param> for the flashVars. It seems that the swf <object> loaded the <param > elements
within it and kept using the initial <param > even though the <param> elements are updated or new <param > elements are added later.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create the entire object, not just the parameter.

Eric
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to reload the <object > with an event?
 
reply
    Bookmark Topic Watch Topic
  • New Topic