Retrieve tag content
Hi, I am new of JSP and I want to do this:
for example I have this line in my HTML page:
<span> xxx </span>
when I press a button of a form I want to pass the string xxx to a Java Bean, how can I do that? of course the tag content changes dinamically.
Thank you!
[305 byte] By [
mangustaa] at [2007-10-3 1:18:07]

It would have to be javascript. Give the element an ID and then you can retrieve the content using the innerHTML element. I'm not sure if the span element supports this, the div does.
<div id="yourdiv">bla bla bla</div>
<form name="yourform" method="post" action="yourjsp.jsp">
<input type="hidden" name="divcontent" value="">
<input type="button" value="submit" onClick="doSubmit();">
</form>
When submitting do the following:
function getElement(id)
{
if(document.all) { return document.all[id]; }
return document.getElementById(id);
}
function doSubmit()
{
document.yourform.divcontent.value = getElement('yourdiv').innerHTML;
document.yourform.submit();
}
That should work, if I didn't make a typo somewhere (typed from memory)