<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>
<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>
解决方案 »
- 一个table表格, 四个按钮分别为(增加一行,删除一行,增加一列,删一行)谁有javascript代码,请高手帮帮我。。。发我邮箱也可以[email protected]一定给分
- 求解释这个链接冒号 http://codex.wordpress.org/zh-cn:Main_Page
- thickbox怎么自动弹出层?
- 关于文字颜色渐变的效果
- 这样的功能可以实现吗
- 急急, 怎样控制单选框的提交?就是不选的话不让提交???javasrcipt脚本,在线等。。。。。。
- 用JAVASCRIPT如何区分两个有相同NAME ,ID的AREA控件,在线等待------
- 为什么在frame里的内容超过最大宽度的时候,不显示滚动条,而是换行了?在线等?
- innerHTML outerHTML谁帮忙解释一下吧,我理解不深
- 求助:一个表单中有多个input,数量不确定,怎么验证不为空,一次性提交后,怎么获取到值?
- CSDN社区结贴给分器,觉得还能用的就顶一下呀,让更多的人不用一个一个的给分,麻烦啊
- 帮我写一段js,急等!
<input type="text" name="price" onKeyUp="count_price(this);" ID=Text1>
<input type="text" name="price" onKeyUp="count_price(this);" ID=Text2>
<input type="text" name="price]" onKeyUp="count_price(this);" ID=Text3>
</form>
<script>function count_price(obj)
{ var objlen=document.getElementsByName("price").length;
for(var i=0;i<objlen;i++)
{
if(document.getElementsByName("price")[i].id==obj.id)
{
alert(i);
}
}
}</script></body>
<input type="text" name="price[]" onKeyUp="count_price(this);" ID=Text1>
<input type="text" name="price[]" onKeyUp="count_price(this);" ID=Text2>
<input type="text" name="price[]" onKeyUp="count_price(this);" ID=Text3>
</form>
<script>function count_price(obj)
{ var objlen=document.getElementsByName("price[]").length;
for(var i=0;i<objlen;i++)
{
if(document.getElementsByName("price[]")[i].id==obj.id)
{
alert(i);
}
}
}</script></body>