Anchor onclick attribute
-
Hi, Below is the issue I am facing in Java script. I am using <TR> in that Tr i have 3 <Td> in last <td> I am using anchor tag dome thing like below <tr name =row> <td/> <td/> <td> <a type="aaa" onclick="UpdateName" > test </a> I am assigning dynamically all the attributes of anchor tag like below var cells= row.cells; var link = cells(2).all.tags("A")(0); link.file= "123"; link.href = "javascript:VoidReturn("nothing to return"); link.onclik=function() { updateName(name);} function Update(name) { username=name; } This is working fine if i am using link onclick attribute as above ...function() { updateName(name);} but if i am just giving it as string, it is not invoking, like below. link.onclick=updateName('abc'); Please let me know how i can set onclick of anchor attribute without function object. Thanks, Salmon
-
Hi, Below is the issue I am facing in Java script. I am using <TR> in that Tr i have 3 <Td> in last <td> I am using anchor tag dome thing like below <tr name =row> <td/> <td/> <td> <a type="aaa" onclick="UpdateName" > test </a> I am assigning dynamically all the attributes of anchor tag like below var cells= row.cells; var link = cells(2).all.tags("A")(0); link.file= "123"; link.href = "javascript:VoidReturn("nothing to return"); link.onclik=function() { updateName(name);} function Update(name) { username=name; } This is working fine if i am using link onclick attribute as above ...function() { updateName(name);} but if i am just giving it as string, it is not invoking, like below. link.onclick=updateName('abc'); Please let me know how i can set onclick of anchor attribute without function object. Thanks, Salmon
salmonraju wrote:
link.onclik=function() { updateName(name);}
OK the above assigns the Function to the onclick . Now this next part assigns the results of updateName('abc') (which is a function call) to the onclick , you don't want that.
salmonraju wrote:
link.onclick=updateName('abc');
I can't do anything with the code you presented so I will give this simple example ...
<table>
<tr name="row">
<td>
<a name="a1">a1</a>
<td/>
<td>
<a name="a2">a2</a>
<td/>
</tr>
</table>
<script>
as = document.getElementsByTagName("A")as[0].href = '#';
as[0].innerHTML = "HIYAS";
as[0].onclick = Update;
as[0].aname = "Davey"as[1].href = '#';
as[1].innerHTML = "Whassup";
as[1].onclick = Update;
as[1].aname = "JONES"function Update()
{
alert(this.aname);
}
</script>Try that out and see if it works for you.
-
salmonraju wrote:
link.onclik=function() { updateName(name);}
OK the above assigns the Function to the onclick . Now this next part assigns the results of updateName('abc') (which is a function call) to the onclick , you don't want that.
salmonraju wrote:
link.onclick=updateName('abc');
I can't do anything with the code you presented so I will give this simple example ...
<table>
<tr name="row">
<td>
<a name="a1">a1</a>
<td/>
<td>
<a name="a2">a2</a>
<td/>
</tr>
</table>
<script>
as = document.getElementsByTagName("A")as[0].href = '#';
as[0].innerHTML = "HIYAS";
as[0].onclick = Update;
as[0].aname = "Davey"as[1].href = '#';
as[1].innerHTML = "Whassup";
as[1].onclick = Update;
as[1].aname = "JONES"function Update()
{
alert(this.aname);
}
</script>Try that out and see if it works for you.