Link to home
Start Free TrialLog in
Avatar of arkam chou
arkam chou

asked on

Get value from HTML Tag (span)

Dear All,

How can I get value from span?
<form action="" method="POST">
<span id="test">2015-06-10 - 2015-06-21</span>
</form>

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

With javascript you can do the following

var s = document.getElementById('test').innerHTML;
var d = document.getElementById('test').textContent || document.getElementById('test').innerText;

With JQuery

var x = $('#test').text();
var y = $('#test').html();

If you want to submit the value with the form and retrieve it on the server - can't
Avatar of arkam chou
arkam chou

ASKER

yes, I want to submit that value with php. I want to get date value from span in bootstrap-datepicker and submit that value to php.
https://bootstrap-datepicker.readthedocs.org/en/latest/options.html
can I transfer value from span to hidden textbox when have any change on span? if can, how to do it?
can I transfer value from span to hidden textbox when have any change on span?
I don't understand - <span> is not an input element - it contains static text so not sure what you mean when you say "have any change on span"?
I use https://bootstrap-datepicker.readthedocs.org/en/latest/options.html 
when I pick any date, it will give value to span. so I want to use that value in span with form.
when I pick any date, it will give value to span
A) How?
B) Why?

Why are you assigning a date to a span and not an input element?
I not assign it myself. I use date-picker from this web https://bootstrap-datepicker.readthedocs.org/en/latest/options.html 
and I saw when I pick date, the value was change in span.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial