I have 4 buttons with same id (for css purpose) I want to highlight the button once it is clicked. By passing the id it is working fine, but I want to pass the names of the button (unique name). when i am trying getElementByNames() its not working. here is the code with DIFFERENT ID, i want this for different names
<html>
<head>
<style type="text/css">
</style>
<script type="text/javascript">
var buttonClicked = null;
function highlight(id)
{
if(buttonClicked != null)
{
buttonClicked.style.background = "grey";
buttonClicked.style.color="black";
}
buttonClicked = document.getElementById(id);
buttonClicked.style.background = "blue";
buttonClicked.style.color="white";
}
</script>
</HEAD>
<BODY>
<table width="100%" cellspacing="0" cellpadding="3px">
<tr>
<td>
<input type="button" value="BUTTON" id="select1" name="select1" onclick="highlight('select1')">
</td>
<td>
<input type="button" value="BUTTON" id="select2" name="select2" onclick="highlight('select2')">
</td>
<td>
<input type="button" value="BUTTON" id="select3" name="select3" onclick="highlight('select3')">
</td>
<td>
<input type="button" value="BUTTON" id="select4" name="select4" onclick="highlight('select4')">
</td>
</tr>
</table>
</BODY>
</HTML>