Uncaught SyntaxError: missing) after argument list

0

What happens is that I need to perform an exercise that fills me with a php class or show me a list.

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","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">\n\
            <option value="">Select please... </option>\n\
    <?php $ObjUtilidades->Select("prod_codigo, prod_descripcion","productos", "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%;">\n\
                <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>

Ready, there's a good one, show me what the list is ... List: Data        Data and so What I want is that with the JavaScript to do so I show the list again ... In the inspection I see the list and if it is displayed ... But in the inspection but not in the list. It says the error: Uncaught SyntaxError: missing) after argument list

The error is clear, missing a parenthesis but check the code and I have nothing to close ...

    
asked by Her Asd 14.10.2016 в 16:09
source

3 answers

0

The solution to the problem was that I needed the list of that PHP code when I could not use it, what I did was put it this way:

<tbody id="agrega">
                                 <tr>
                                    <td><label>Producto 1</label></td>
                                    <td id="listaproducto"><select  id='producto1' name='producto[]' class="form-control" value='<?php echo $producto1 ?>'>

                                    <option value="">Selecciona </option>
                                    <?php
                                          $ObjUtilidades->CargaSelectGeneral("prod_codigo, prod_descripcion","productos", $producto, "prod_descripcion", "where prod_indicativo=1");
                                     ?>
                                    </select>

                                    <td><label >&nbsp;&nbsp;&nbsp;Consumo&nbsp;&nbsp;&nbsp</label></td>
                                    <td id="listaconsumo"><input type="text" name="consumo[]" id="consumo1" placeholder="Ingrese cantidad a consumir" maxlength='100' class="form-control" size='3' value="<?php echo $consumo1?>"></td>
                                </tr>
                            </tbody>

Afterwards, what I did was simply:

var contador0=1;

function agregar_campos_kts(){
    contador0++;
    $('#cta_campos').val(contador0);

    $('<tr class="contra'+contador0+'">\n\
    <th><p>Producto '+contador0+'</p></th><td id="producto'+contador0+'" ></td>\n\
    <th><p>&nbsp;&nbsp;&nbsp;Consumo&nbsp;&nbsp;&nbsp '+contador0+'</p></th>\n\
    <td id="consumo'+contador0+'"></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></tr>').appendTo("#agrega");

    $("#listaproducto").clone().appendTo("#producto"+contador0).addClass( "listkts" );

    $("#listaconsumo").clone().appendTo("#consumo"+contador0).addClass( "listkts" );

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

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

    });}

It looks messy but good, what I did was use a .clone () and to add style to the list and input I did was put a .addClass for the style and that's it, that worked perfectly, cloning the list .

Well I myself found the solution and here I share it.

    
answered by 18.10.2016 / 19:23
source
1

change this

<?php $ObjUtilidades->Select("prod_codigo, prod_descripcion","productos","prod_descripcion", "where prod_indicativo=1"); ?>

for this

<?php $ObjUtilidades->Select("prod_codigo", "prod_descripcion","productos","prod_descripcion", "where prod_indicativo=1"); ?>

You closed the comrades wrong in prod_codigo

Greetings

    
answered by 16.10.2016 в 00:18
-1

Since I can not comment because I'm new.

My answer is that if you want to use PHP inside javascript, do it backwards Generate all your javascript code with php,

echo '<script></script>'

Although what I recommend is to use AJAX to make requests from javascript to php and just render.

As they say in the comments, there are many examples of all this

Greetings

    
answered by 14.10.2016 в 19:25