Un pequeño ejemplo de lo que quiero realizar
Código PHP:
<html>
<head>
</head>
<body>
<div id="botonera">
<input type="button" id="Boton1" name="Boton1" value="Enviar" />
<input type="button" id="Boton2" name="Boton2" value="Enviar" />
<input type="button" id="Boton3" name="Boton3" value="Enviar" />
</div>
<script type="text/javascript">
function evento(elemento,nomevento,funcion)
{
if (elemento.attachEvent)
{
elemento.attachEvent('on'+nomevento,funcion);
return true;
}
else
if (elemento.addEventListener)
{
elemento.addEventListener(nomevento,funcion,false);
return true;
}
else
return false;
}
var bot = document.getElementById("botonera").getElementsByTagName("input");
for (var i=0; i<bot.length; i++) {
evento(bot[i], "click", function(){
if (this.id = "Boton1") {
Cambiar1()
}
if (this.id = "Boton2") {
Cambiar2()
}
if (this.id = "Boton3") {
Cambiar3()
}
});
}
function Cambiar1()
{
document.getElementById("Boton1").value = "A";
}
function Cambiar2()
{
document.getElementById("Boton2").value = "B";
}
function Cambiar3()
{
document.getElementById("Boton3").value = "C";
}
</script>
</body>
</html>
Código PHP:
if (this.id = "Boton1") {
Cambiar1()
}
else
if (this.id = "Boton2") {
Cambiar2()
}
else
if (this.id = "Boton3") {
Cambiar3()
}
else
{
return false;
}
Gracias