Onclick event
Posted: Tue Apr 16, 2019 9:34 pm
I have a page here : http://communitylifestyleaccommodation. ... board.html
When a name is clicked in the buttons, I trigger the onclick and created a show picture of the relevant person
But now, I want to get the text of the button clicked and show it as a label under that picture.
I must be doing something wron, it doesn't show the text - here below is the function I created.
I inserted a text item under the picture, ID=Text38
<script>
function ShowName()
{
var buttonid = event.srcElement.id; // works ok
var buttontext = document.getElementById(buttonid).value; // works ok
alert(buttontext); // Show the text
document.getElementById('Text38').setAttribute("value", buttontext); // Does NOT WORK
}
</script>
Any suggestions
Thanks
When a name is clicked in the buttons, I trigger the onclick and created a show picture of the relevant person
But now, I want to get the text of the button clicked and show it as a label under that picture.
I must be doing something wron, it doesn't show the text - here below is the function I created.
I inserted a text item under the picture, ID=Text38
<script>
function ShowName()
{
var buttonid = event.srcElement.id; // works ok
var buttontext = document.getElementById(buttonid).value; // works ok
alert(buttontext); // Show the text
document.getElementById('Text38').setAttribute("value", buttontext); // Does NOT WORK
}
</script>
Any suggestions
Thanks