Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I get the values of span tags

How Do I get the value of a span tag and send it into my form to another page?

<span id="subtotal"></span>

I need to send the content of my span tag subtotal to another page, I would like to save it into a hidden field, but I found no way to do this..

I used this, but no success!

function getTotal() {
    return alert(document.getElementById('total').innerHTML);
}

Here goes the right function for those who need the answer! After I figured out the script ...

function getTotal() {
    //document.write(document.getElementById('total').innerHTML);
    var someValue = $(".total").text();
    alert("Value is "+someValue);
    //It cause to releoad the page and give me the parameter total          
    location.href="frmAdd.php?total=" + someValue; 
}
like image 823
devasia2112 Avatar asked Nov 25 '10 20:11

devasia2112


1 Answers

this will give you value

$("#subtotal").text();
like image 121
kobe Avatar answered Oct 12 '22 14:10

kobe