B
Bob
This seems to me like it should work but I get "generic" no matter
which button I click. Javascript is not one of my better languages.
Can the experts here take a look at this and tell me what I'm doing
wrong.
Thanks, Bob
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<div id="zz" />
<script language="JavaScript1.2">
function btn(txt){
this.click = function(){ alert('generic');}
this.b = document.createElement("INPUT");
with (this.b){
type = 'button';
value = txt;
onclick = this.click;
}
return(this);
}
var btnA = new btn('button A');
document.all.zz.appendChild(btnA.b);
var btnB = new btn('button B');
document.all.zz.appendChild(btnB.b);
btnA.prototype.click = function(){ alert('button A pressed');}
</script>
<p>Button A should show "button A pressed",<br>
Button B should show "generic"
</BODY>
</HTML>
which button I click. Javascript is not one of my better languages.
Can the experts here take a look at this and tell me what I'm doing
wrong.
Thanks, Bob
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<div id="zz" />
<script language="JavaScript1.2">
function btn(txt){
this.click = function(){ alert('generic');}
this.b = document.createElement("INPUT");
with (this.b){
type = 'button';
value = txt;
onclick = this.click;
}
return(this);
}
var btnA = new btn('button A');
document.all.zz.appendChild(btnA.b);
var btnB = new btn('button B');
document.all.zz.appendChild(btnB.b);
btnA.prototype.click = function(){ alert('button A pressed');}
</script>
<p>Button A should show "button A pressed",<br>
Button B should show "generic"
</BODY>
</HTML>