Javascript -- inner HTML question

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);
LVL 1
nachtmskAsked:
Who is Participating?
 
Rainer JeschorConnect With a Mentor Commented:
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
 
nachtmskAuthor Commented:
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
 
COBOLdinosaurCommented:
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
 
COBOLdinosaurCommented:
Ooops too slow again. ;^)

Cd&
0
All Courses

From novice to tech pro — start learning today.