Hunter Mitchell Hunter Mitchell - 1 year ago 128
HTML Question

Get value of Span Text

I have a span with

and a hidden field

text changes, and I need to grab the text and set it as the value of the hidden field's value.

I will then use php (I already have) and use the name of the hidden field to email me the text.

How do I do it?

Answer Source
<script type="text/javascript">
document.getElementById('button1').onChange = function () {
    document.getElementById('hidden_field_id').value = document.getElementById('span_id').innerHTML;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download