使用php

时间:2016-10-13 20:13:38

标签: javascript php

在我的主函数调用和自动完成列表之后;我使用按钮Add也这样做,但这对我不起作用。因此我想向您咨询错误。

的index.php

<div class="container">
  <table class="table table-bordered">
    <tr>
      <th colspan="5">
        List
      </th>
    </tr>
    <tr>
      <th>
        Producto 1:
        <input type="hidden" name="cta" value="<?php echo $cta; ?>">
      </th>
      <td>
        <select id="list" class="form-control" name="list" required>
          <option value="">Select please...</option>
          <?php $ObjUtilidades->Select("prod_codigo, prod_descripcion","productos", $producto, "prod_descripcion", "where prod_indicativo=1"); ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>
        <div id="listadd"></div>
      </td>
    </tr>
  </table>
  <table>
    <tr>
      <td colspan="2">
        <button type="button" name="button" class="btn btn-primary" onclick='agregar_campos_kts()'>Add</button>
      </td>
    </tr>
  </table>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript">
    var contador0=1;
    function agregar_campos_kts()
    {
            contador0++;
            $('#cta_campos').val(contador0);

            $( '<tr class="contra'+contador0+'"><td><p>Producto '+contador0+' </p></td>\n\
            <td colspan="3"><select  id="producto1" name="producto1" class="form-control" value="'+"<?php echo $producto1 ?>"+'">\n\
            <option value="">Select please... </option>\n\
    <?php $ObjUtilidades->Select("prod_codigo, prod_descripcion","productos", $producto, "prod_descripcion", "where prod_indicativo=1"); ?>\n\
            </select></td>\n\
                <td><p>Consumo</p></td>\n\
                <td><input type="text" class="form-control" id="consumo'+contador0+'" name="consumo[]" required dir="rtl" ></td>\n\
                <td style="color:transparent;border:none;background:url(../img/deletered.png)  no-repeat;no-repeat;background-size:90% 60%;margin-top:3% 0% 0% 0%;">\
                <input type="button"  id="elimi'+contador0+'" class="eliminar"  value="'+contador0+'" ></td>\n\
            </tr>alert(contador)').appendTo( "#listadd" );

        $("input.eliminar").click(function()
            {
                var es=alert('Seguro que desea Eliminar');

                        var estu=$(this).attr("value");
                        $(".contra"+estu).remove();

            });

    }
    </script>

ClassUtilities.php

function Select($field,$table, $state, $sortby, $condition){
$sql="select $field FROM $table $condition orderby $sortby";
echo "$stateñlñlñl<br>";
    $reg=mysql_query($sql);
$num=mysql_num_rows($reg);
if($num>0)
{
  while ($data=mysql_fetch_row($reg))
  {
    if($state==$data[0])
    {
      echo"<option value='".$data[0]."' selected>$data[1]</option>";
    }
    else
    {
      echo"<option value='".$data[0]."'>$data[1]  </option>";
    }
  }
}}

解决了onclick的问题?在选择函数javascript中,不加载任何内容。

0 个答案:

没有答案