aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes access javascript DOM object value from HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "access javascript DOM object value from HTML" Watch "access javascript DOM object value from HTML" New topic
Author

access javascript DOM object value from HTML

mark I thomas
Ranch Hand

Joined: Apr 07, 2008
Posts: 86
I have a html page that includes lot of javascript. In a portion of the html, I was trying to create some html content that needs to get the value of some DOM object. For example, I want to do somthing like
*********
<script type="text/javascript" ..."some javascript" ...></script>
....
....


The name is --
<!-- want to print value of this.myBox.name -->


********
"myBox" is an object defined in "some javascript" that the current HTML includes. Of course at the point where we create

the "myBox" is already created and has its value. The dilemma is I know how to access this value inside another javascript code snippet, but how do I get that value in my html ?

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
can you show us some actual code? Maybe create a small example that illustrates what you are trying to do.

Eric
mark I thomas
Ranch Hand

Joined: Apr 07, 2008
Posts: 86
In test.js:

**********
function Mybox() {
this.name = "test";
....
....


}

function alterName(e) {

this.mybox.name = e.value;
}
**********

In test.html:

<script type="text/javascript" src="test.js"/>

<body>

<div>
The box name is

<!-- try to access mybox.name value and append it here !! -->
</div>

</body>

**************

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Please UseCodeTags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
mark I thomas
Ranch Hand

Joined: Apr 07, 2008
Posts: 86
In test.js:

**********

**************



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Did you even look at your post after you made it? Does the code look any better? Please read on how to use code tags again. I have fixed the post for you this time.
 
Consider Paul's rocket mass heater.
 
subject: access javascript DOM object value from HTML