<html>
<head>
<title>Purhcase Order 蹦潦虫</title>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<link rel="stylesheet" href="images/style.css" type="text/css">
<SCRIPT LANGUAGE=javascript>
<!--
var rowIndex = 0;
function AddOneLine_onclick() 
{
var row = Table1.insertRow(Table1.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input name=Category id=Category size=20>";
col = row.insertCell(1);
col.innerHTML = " <textarea name=Description id=Description rows=2 cols=35></textarea>";
col = row.insertCell(2);
col.innerHTML = " <input type=text name=Qty id =Qty size=4 onchange='getTo(this);'>";
col = row.insertCell(3);
col.innerHTML = " <input type=text name=UnitPrice id=UnitPrice size=10 onchange='getTo(this)'>";
col = row.insertCell(4);
col.innerHTML = "<input type=text readonly>";
col = row.insertCell(5);
col.innerHTML = "<INPUT type='button' value='埃' id=button1 name=button1 LANGUAGE=javascript onclick=\"return Delete_Row('row" + rowIndex + "')\">";
row.setAttribute("id", "row"+rowIndex); 
row.setAttribute("name", "row"+rowIndex); 
rowIndex++;
}
function getTo(obj){
var trobj = obj.parentElement.parentElement;

var qty = parseFloat(trobj.childNodes(2).childNodes(0).value);
var uprice = parseFloat(trobj.childNodes(3).childNodes(0).value);
if (qty>0 && uprice>0){
trobj.childNodes(4).childNodes(0).value = uprice*qty;
}}
function Delete_Row(rowTag)
{
var i = Table1.rows(rowTag).rowIndex;
Table1.deleteRow(i);
rowIndex--;
}
</script>
</head>
<body bgcolor="ffffff">
<form method="post" action="#" name="form1" onsubmit="return check();">
    <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#e6e6e6" id="Table1">
    <tr bgcolor="#CCCCCC"> 
      <td height="17" width="15%">祑ン摸</td>
      <td width="41%">磞瓃</td>
      <td width="21%" height="17">计秖</td>
      <td width="8%" height="17">虫基</td>
  <td>&nbsp;</td>
      <td colspan="3" height="17" width="15%">巨</td>
    </tr>
<SCRIPT LANGUAGE=javascript>
AddOneLine_onclick();
</SCRIPT>
  </table>
        <table width="100%" border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="eeeeee">
    <tr> 
      <td height="25" colspan="4"><font color="006699"></font> 
      </td>
      <td colspan="3" height="25">&nbsp;</td>
    </tr>          <tr> 
            <td width="42%"> 
 <input type="button" name="add" value="穝糤兜ヘ" onClick="javascript:return AddOneLine_onclick();" >          
            </td>
            <td width="58%"> 
              <input type="submit" name="Submit" value="絋﹚">
              <input type="reset" value="糶" name="reset">
              <input type="button" name="Submit3" value="" onClick="javascript:location.href='selectProject.jsp?type=PO';">
            </td>
          </tr>
        </table>
        <input type="hidden" name="ProjectNo" value="YNK-200111095">
  </form>
</body>
</html>

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script language="JavaScript">
    function getTotal(price,count,obj)
    {
    var Total=price*count;
    obj.value=Total;
    }
    </script>
    <body>
    单价:<input name="Price" type="text" id="Price" onBlur="getTotal(this.value,window.Count.value,window.Total)">
      <br>
    数量:<input name="Count" type="text" id="Count" onBlur="getTotal(window.Price.value,this.value,window.Total)">
      <br>
    小计:<input name="Total" type="text" id="Total">
    </p>
    </body>
    </html>
      

  2.   

    gzh_seagull(不可):多谢不可兄,你就是传说中的JAVASCRIPT王子啊,呵呵,多谢,以后有问题还请教你,OKAY??我马上给你加分!!!接着了!!
      

  3.   

    gzh_seagull(不可):如果程序代码改为这样,应该如何来写JAVASCRIPT呢???因为我需要在一个TD 里面放三个textfield, qyt,unitprice ,total,每个TD里面都放三个TEXT FIELD, 需要有多个TD,该如何写呢??
    这个  trobj.childNodes(2).childNodes(0).value  应该怎么来使用的?
    多谢了,代码如下!!!<html>
    <head>
    <title>Purhcase Order 蹦潦虫</title>
    <meta http-equiv="Content-Type" content="text/html; charset=BIG5">
    <link rel="stylesheet" href="images/style.css" type="text/css">
    <SCRIPT LANGUAGE=javascript>
    <!--
    var rowIndex = 0;
    function AddOneLine_onclick() 
    {
    var row = Table1.insertRow(Table1.rows.length);
    var col = row.insertCell(0);
    col.innerHTML = "<input name=Category id=Category size=20>";
    col = row.insertCell(1);
    col.innerHTML = " <textarea name=Description id=Description rows=2 cols=35></textarea>";
    col = row.insertCell(2);
    col.innerHTML = " <input type=text name=Qty id =Qty size=4 onchange='getTo(this);'> <input type=text name=UnitPrice id=UnitPrice size=10 onchange='getTo(this)'> <input type=text readonly>";
    col = row.insertCell(3);
    col.innerHTML = " <input type=text name=Qty1 id =Qty1 size=4 onchange='getTo(this);'> <input type=text name=UnitPrice1 id=UnitPrice1 size=10 onchange='getTo(this)'> <input type=text readonly>";
    col = row.insertCell(4);
    col.innerHTML = "";
    col = row.insertCell(5);
    col.innerHTML = "<INPUT type='button' value='埃' id=button1 name=button1 LANGUAGE=javascript onclick=\"return Delete_Row('row" + rowIndex + "')\">";
    row.setAttribute("id", "row"+rowIndex); 
    row.setAttribute("name", "row"+rowIndex); 
    rowIndex++;
    }
    function getTo(obj){
    var trobj = obj.parentElement.parentElement;

    var qty = parseFloat(trobj.childNodes(2).childNodes(0).value);
    var uprice = parseFloat(trobj.childNodes(3).childNodes(0).value);
    if (qty>0 && uprice>0){
    trobj.childNodes(4).childNodes(0).value = uprice*qty;
    }}
    function Delete_Row(rowTag)
    {
    var i = Table1.rows(rowTag).rowIndex;
    Table1.deleteRow(i);
    rowIndex--;
    }
    </script>
    </head>
    <body bgcolor="ffffff">
    <form method="post" action="#" name="form1" onsubmit="return check();">
        <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#e6e6e6" id="Table1">
        <tr bgcolor="#CCCCCC"> 
          <td height="17" width="15%">祑ン摸</td>
          <td width="41%">磞瓃</td>
          <td width="21%" height="17">计秖</td>
          <td width="8%" height="17">虫基</td>
      <td>&nbsp;</td>
          <td colspan="3" height="17" width="15%">巨</td>
        </tr>
    <SCRIPT LANGUAGE=javascript>
    AddOneLine_onclick();
    </SCRIPT>
      </table>
            <table width="100%" border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="eeeeee">
        <tr> 
          <td height="25" colspan="4"><font color="006699"></font> 
          </td>
          <td colspan="3" height="25">&nbsp;</td>
        </tr>          <tr> 
                <td width="42%"> 
     <input type="button" name="add" value="穝糤兜ヘ" onClick="javascript:return AddOneLine_onclick();" >          
                </td>
                <td width="58%"> 
                  <input type="submit" name="Submit" value="絋﹚">
                  <input type="reset" value="糶" name="reset">
                </td>
              </tr>
            </table>
    </form>
    </body>
    </html>