Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

applet param as js variable

Status
Not open for further replies.

kimgokce

Programmer
Jan 5, 2001
4
US
I have fumbled blindly around in every sort of doc on and off line to locate how (if possible) to assign a js variable as the value of an applet param tag generated in a "document.write" applet script.
I have found one or two syntax options but neither has helped at all. I am tapped out and I see a couple of other similiar threads around with no resolution.

Here's my statement out of context. It is one of twenty such elements of an applet tag. All the others are static assignments that work fine and the applet tag is published and loads the applet fine.

document.write(&quot;<PARAM NAME=\&quot;links3\&quot; VALUE=\&quot; + portal\&quot;>&quot;);

where 'portal' is a global var in the same page assigned to the value of document.referrer. This assignment is confirmed via a document.write on the resulting html page.

I found on another forum a sample like:

document.write '<param name=MAPFILE value=&quot;' + siteMapUri + '&quot;>

but that led no where no matter how I tweaked the syntax. Any insights would be salve for my wounds. I need to support NS4x &amp; IE4.x in this implementation. Seasons Greetings! -Kim

 
Both pieces of code do have syntax errors:
correction for first is
Code:
   document.write(&quot;<PARAM NAME=\&quot;links3\&quot; VALUE=\&quot;&quot; + portal + &quot;\&quot;>&quot;);
note doubled double-quotes around
Code:
 + portal +
. Reason is that
Code:
\&quot;
denotes quotes as part of string that we want to write to document and others denotes bounds of string literals. Note that if portal is not string variable you should (but not must - behaviour may vary) use
Code:
portal.toString()
construct - to be sure that operator
Code:
+
will be understood as string concatenation operator.
Second part of code seems to be VBScript. It's basic style - call to function without parentheses. But this example is incorrect too. In VBScript (as in any Basic) you can't use single quotes (
Code:
'
) as string literal - single quote starts line comments in Basic.
so you should use either code above or this one (if have trouble understanding what backslash (
Code:
\
) means. :)
Code:
   document.write('<PARAM NAME=&quot;links3&quot; VALUE=&quot;' + portal + '&quot;>');


Michael Dubner
Brainbench MVP/HTML+JavaScript

 

Thanks, Michael! I had fiddled around with the syntax so much I did not even consider the fact that I was trying to write a string! That was the key.

After using toString(), the flood gates opened! I am humbled and grateful. An old saw always worth being reminded of ...

for want of a nail, the shoe was lost
for want of a shoe, the horse was lost
for want of a horse, the rider was lost
for want of a rider, the battle was lost

Thanks for the nail! Now to battle ...
Best Wishes in 2001!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top