Another Weerd One. I got an insert row function running with bObj but wanted to add some flexibility to the function and decided to add some if statements to it but can’t figure out why it isn’t working as exspected.
[B][U]SCRIPT
[CODE]
function addtoinvoice(){
var bObj=document.getElementsByClassName(‘button’);
for(var i=0; i< bObj.length; i++)
{
if(bObj[i].innerText==’Buy More!’) //added if to test button change?
{
bObj[i].onclick = function()
{
//alert(‘Yeah!’);
alerted();//should work!!
return;//to avoid rest of script
}
if(bObj[i].innerText===’Buy Now!’)
{
bObj[i].onclick = function()
{
//alert(bObj[0].innerText);
additem(this);
}
}
};
}
function additem(button)//oh that’s it have to reference button??
{
alert(this.innerText);
}
//onclick doesn’t run at all??
function alerted(button)//refferenced button
{
alert(this.innerText);
}
//this should work?
Any advice greatly appreciated.:p