Hello again :) I have following code :
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$(function () {
$('body').on('click', 'a.myclass', function () {
sndcmpnm = $(this).attr("value");
alert("From Small Function :" + sndcmpnm);
});
});
});
</script>
In the page at the bottom, I have a simple javascript with the line var deares = sndcmpnm; The funny thing is that no matter what I do, deares never gets the value of sndcmpnm. I tried another solution from SO, which said I must not put var infront of the variable but that also did not help. The alert alert("From Small Function :" + sndcmpnm); gives the right result. The java error code thingy says
ReferenceError: sndcmpnm is not defined
All I want is that deares can get the value of sndcmpnm. I don't see what I am doing wrong, please help me :(
[EDIT] Other code :
<script>
function discomp()
{
alert("hello1");
var deares = sndcmpnm;
alert("hello2");
alert("This is suppose to hold the sndcmpnm data :" +deares);
}
</script>
discompis executed before the click event handler (and hencesndcmpnmis never set). Also, JavaScript has nothing to do with Java.