473,394 Members | 1,845 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,394 software developers and data experts.

accessing javascript variables in HTML

ksr
Hello,

I have a HTML page, which loads an activeX control in the browser.
In the <HEADsection, I have javascript similar to the following,

<SCRIPT language="JavaScript">
var Index = "";
// do some processing which sets a value to variable Index
</SCRIPT>

In the <BODYsection, I am downloading the cab file, which is an
activeX control, so the code is,

<BODY TEXT="#000000" BGCOLOR="#FFFFFF"..........>
<OBJECT ID="objID" CLASSID=...."CODEBASE="..>
<param name="name" value=..>.

</OBJECT>
</BODY>
</HTML>

In the param name=value pair, I want to assign the variable Index to
value. Just by doing value=Page, it does not work. Could someone
suggest how I can access javascript variable here?

Thankyou.

Aug 25 '06 #1
2 13133
Hi,

ksr wrote:
Hello,

I have a HTML page, which loads an activeX control in the browser.
In the <HEADsection, I have javascript similar to the following,

<SCRIPT language="JavaScript">
var Index = "";
// do some processing which sets a value to variable Index
</SCRIPT>

In the <BODYsection, I am downloading the cab file, which is an
activeX control, so the code is,

<BODY TEXT="#000000" BGCOLOR="#FFFFFF"..........>
<OBJECT ID="objID" CLASSID=...."CODEBASE="..>
<param name="name" value=..>.

</OBJECT>
</BODY>
</HTML>

In the param name=value pair, I want to assign the variable Index to
value. Just by doing value=Page, it does not work. Could someone
suggest how I can access javascript variable here?

Thankyou.
HTML is a static language, so it cannot access JavaScript variables. It
has to go the other way round, with JavaScript setting the HTML value.
Thankfully, with DOM Level 2 it has become much easier to do this kind
of things.

My suggestion is to set an ID on your PARAM node, and then use
document.getElementById to get it.

<param name="name" id="name" value="...">

Note that the ID must be unique throughout the whole HTML document.

Then:

var nParam = document.getElementById( "name" );
if ( nParam != null )
{
nParam.setAttribute( "value", Index );
}
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 26 '06 #2
ksr
Thanks for your reply.
I am new to DOM.
Can you post an example (syntax), for html page similar to that I
posted?
Thankyou.

Laurent Bugnion wrote:
Hi,

ksr wrote:
Hello,

I have a HTML page, which loads an activeX control in the browser.
In the <HEADsection, I have javascript similar to the following,

<SCRIPT language="JavaScript">
var Index = "";
// do some processing which sets a value to variable Index
</SCRIPT>

In the <BODYsection, I am downloading the cab file, which is an
activeX control, so the code is,

<BODY TEXT="#000000" BGCOLOR="#FFFFFF"..........>
<OBJECT ID="objID" CLASSID=...."CODEBASE="..>
<param name="name" value=..>.

</OBJECT>
</BODY>
</HTML>

In the param name=value pair, I want to assign the variable Index to
value. Just by doing value=Page, it does not work. Could someone
suggest how I can access javascript variable here?

Thankyou.

HTML is a static language, so it cannot access JavaScript variables. It
has to go the other way round, with JavaScript setting the HTML value.
Thankfully, with DOM Level 2 it has become much easier to do this kind
of things.

My suggestion is to set an ID on your PARAM node, and then use
document.getElementById to get it.

<param name="name" id="name" value="...">

Note that the ID must be unique throughout the whole HTML document.

Then:

var nParam = document.getElementById( "name" );
if ( nParam != null )
{
nParam.setAttribute( "value", Index );
}
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 27 '06 #3

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

Similar topics

2
by: Tim Blackwell | last post by:
i have some php code pulling some data from a database and i need to access some of hte variables in java script. i've never done this before. how can i do it. eg. i'm loading a combo box...
6
by: J. J. Cale | last post by:
I want to access the DOM. Can something like this be done with PHP or a combination of PHP/JAVASCRIPT? not tested! <html><head><title>DOM test</title> <?php $inFileName = 'test.js'; $outFileName...
3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
8
by: Frédéric Mayot | last post by:
Hi, I have an HTML page like this : --- test.html <html> <body> <form> <iframe id="frametest" name="frametest" src="iframe.html"></iframe> <select multiple...
1
by: Jiri Brada | last post by:
Hi, I have got a following problem with using Javascript: I have a HTML page with pictures' thumbnails. After clicking on any thumbnail, I would like to open a new window with the original...
18
by: Joe | last post by:
Hi, I am trying to alter the refresh rate of an online webpage in a webbrowser control using MFC. However the Timer ID is stored in a local variable and I don't know how to access it. Is there a...
19
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' );...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.