function count_price(obj)
{
 var arrObjs=document.getElementsByName(obj.name);
 alert(arrObjs[0].value);
}

解决方案 »

  1.   

    <form name="tablename">
    <input type="text" name="price[]" onKeyUp="count_price(this);">
    <input type="text" name="price[]" onKeyUp="count_price(this);">
    <input type="text" name="price[]" onKeyUp="count_price(this);">
    </form>
    <script>function count_price(obj)
    {
        var a=document.getElementsByName(obj.name);
        for(var i=0; i<a.length; i++)
        {
            if(a[i]==obj)
            {
                alert("index:"+ i);
                break;
            }
        }
    }
    </script>