this is code
<c:forEach items="${names}" var="jk">
<a href="openmessage" onclick="sendtoanother();" >
<a1>${jk.read}</a1>
<az3>${jk.idnum}</az3>
</a>
</c:forEach>
javascript for selecting the value and showing in alert box
var df = document.getElementsByTagName('az3');
var de = document.getElementsByTagName('a1');
function sendtoanother() {
alert(df+" "+de); }
document.getElementsByTagName
returns a collection.
The first element of this tagname in page has an index 0
.
var df = document.getElementsByTagName('az3')[0];
var de = document.getElementsByTagName('a1')[0];
In df
and de
are HTML elements. You want their .innerHTML
, I suppose.
first get the index value from the list that is by using Jquery click function
var ty;
$(function hj() {
$('a').click(function () {
ty = $(this).index();
alert("this is " + ty);
kill(ty);
});
});
then by passing the variable to another function and with using java script
function kill( tyo) {
var de = document.getElementsByTagName('klw')[tyo].innerHTML;
var df=document.getElementsByTagName('az3')[tyo].innerHTML;
alert("hi " + de);
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.