How to get value from span element in Firefox?

Hi all,

The script below works as expected in IE6 and IE7.  When I try it in FF3, it returns a NaN where IE returns an actual value.  For testing purposes, this script just doubles the selected value in the list and outputs it to a span element.

I've even included an isNaN() test, but it's still not working.

Can anyone make this work in both IE and FF?

Any help much appreciated.

Thank you,

function updateprice(labelParam, selectParam, spanParam) { // output area, number selected, item value
// query DOM set for specific elements by ID
var label = document.getElementById(labelParam);
var name = document.getElementById(selectParam).value;
var spanval = parseInt(document.getElementById(spanParam).value);
if (isNaN(name)) { 
	name = "0"; 
	name = parseInt(name); 
	alert("name problem. val: " + name);
if (isNaN(spanval)) { 
	spanVal = "0"; 
	spanVal = parseInt(spanVal); 
	alert("spanval problem. val: " + spanVal);
var total = parseInt(name)*parseInt(spanval);
msg = "Result: " + total;
label.innerHTML= msg;
    <select name="select1" id="select1" onchange="updateprice('output1','select1','item1');">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
<span id="item1" name="item1" value="2"></span><br>
<span id="output1" name="output1"></span><br>

Open in new window

Who is Participating?
hieloConnect With a Mentor Commented:
var spanval = parseInt(document.getElementById(spanParam).getAttribute("value"));
paulc2000Author Commented:
Short and sweet!  It worked, thank you very much!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.