两个克隆在一个页面中不起作用

时间:2015-03-12 12:16:12

标签: jquery

here i am using two add row function using j query 

首先添加行功能正常但是      第二个添加行功能不起作用我更改整个id和类为第二个添加行功能,但我仍然有添加行的问题。 第二个添加行功能类名称是添加行功能不起作用的模具。

        {include file="./main.tpl"}
        {block name="head"}
        <script type="text/javascript">
        $(document).ready(function() {
          $(".stonecompanyId").blur(function()
          {
            if($(".stonecompanyId:last").val() != '' && $(".stonecompanyId:last").val() > 0)
            {
              $("#one").clone(true).appendTo("#mainDiv")
              .find('input[type="text"]').val('').end()
              .find('select[option=""]').val('');
              var rowCount = $('#mainDiv tr').length;
              $(".srNo:last").val(rowCount);
            }
          });

          $(".mold").blur(function()
          {
            alert("aa");
            if($(".mold:last").val() != '')
            {
              $(".two").clone(true).appendTo(".mainDiv")
              .find('input[type="text"]').val('').end()
              .find('select[option=""]').val('');
              var rowCount = $('.mainDiv tr').length;
            }
          });
        });
        </script>
        {/block}
        <form name="form1" method="POST" action="designMaster.php">
        {block name="body"}
        <table align="center" border="0">
        <tr>
          <td colspan="3"><h2 align="center">Design Create</h2></td>
        </tr>
        <tr>
          <td>Date</td>
          <td>
            {html_select_date prefix=ddate start_year="-1" end_year="+1" field_order="DMY" day_value_format="%02d"}
          </td>
        </tr>
        <tr>
          <td>Item Name</td>
          <td>
            <select name="itemId">
              <option value="">Select Item</option>
                {html_options values=$itemArray.itemId output=$itemArray.itemnm}
            </select>
          </td>
        </tr>
        <tr>
          <td>Worker Name </td>
          <td>
            <select name="workerId">
              <option value="">Select Worker</option>
              {html_options values=$workerArray.workerId output=$workerArray.workerName}
            </select>
          </td>
        </tr>
        <tr>
           <td>Design No</td>
           <td><input type="text" name="dNo"></td>
        </tr>
        <tr>
          <td>Design Weight</td>
          <td><input type="text" name="dWet">
        </tr>
        </table>
        <br><br><br>
        <table align="center" border="1">
          <tr>
            <th>&nbsp;</th>
            <th>Shape</th>
            <th>Stone Size</th>
          </tr>
           <tbody id="mainDiv">
            <tr id="one" class="stonecompanyId">
              <td align="center">
                <input type="text" class="srNo" size="3" value="1" style="text-align:center;" DISABLED />
              </td>
               <td>
                <select name="stonecompanyId[]" class="stonecompanyId">
                  <option value="">Select Shape</option>
                  {html_options values=$comArray.stonecompanyId output=$comArray.stoneName}
                </select>
              </td>
              <td>
                <select name="stoneMasterId[]" class="stoneMasterId[]">
                  <option value="">Select Size</option>
                  {html_options values=$sizeArray.stoneMasterId output=$sizeArray.stoneSize}
                </select>
              </td>
            </tr>
          </tbody>
        </table>
        <br><br>
        <table align="center">
          <tbody class="mainDiv">
            <tr class="two" class="mold">
              <td>Mold</td>
              <td><input type="text" name="mold[]"></td>
            </tr>
          </tbody>
        </table>
        <br><br>
        <table align="center">
        <tr>
          <td class="" colspan="2" align="center"><input type="submit" name="submit" value="Submit"></td>
        </tr>
        </table>
        </form>
        {/block}

0 个答案:

没有答案