Hunter Mitchell Hunter Mitchell - 4 months ago 8
HTML Question

Get value of Span Text

I have a span with

class="span"
and a hidden field
class="dropdown"
.

The
span
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
<script type="text/javascript">
document.getElementById('button1').onChange = function () {
    document.getElementById('hidden_field_id').value = document.getElementById('span_id').innerHTML;
}
</script>
Comments