[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Javascript -- inner HTML question

Posted on 2015-02-10
4
Medium Priority
?
179 Views
Last Modified: 2015-02-10
Hi,

I'm setting the value of a <DIV> using Javascript. Once the value is set, I would like to retrieve it. But when I try using this code all I get is "undefined" in my alert. Could someone help me out here?
Thanks!
Mike
 

var value=500
document.getElementById('aoy_cost').innerHTML = value;
var actor_cost = document.getElementById('aoy_cost').value;
alert(actor_cost);
0
Comment
Question by:nachtmsk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 40601295
Hi,
afaik the value property is just for form/input elements and not for divs. Have you tried to retrieve the innerHTML of the div?
HTH
Rainer
0
 
LVL 1

Author Comment

by:nachtmsk
ID: 40601319
Thanks, that's what I needed to know.
var value=500
document.getElementById('aoy_cost').innerHTML = value;
var actor_cost = document.getElementById('aoy_cost').innerHTML ;
alert(actor_cost);
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40601330
This line is trying to reference what?
var actor_cost = document.getElementById('aoy_cost').value;
There is no such property defined in the script you posted, and it is not a default property.

If you are trying to get the value of some element that is part of what you put in the innerHTML, the you need to reference the element by name or id.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40601335
Ooops too slow again. ;^)

Cd&
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question