Edit parent element that has been clicked

0

Greetings,

In this table I make a selection and in one of the "TD" I have made an INPUT to fill that space with the desired data, all with AJAX and working perfectly, but that I do an INSERT of the INPUT I keep coming out the INPUT box and I would like to change it to the new value I entered. I think a solution would be to be able to select the parent of the clicked item and change its HTML but I do not know how to do it.

I leave the code here.

                               <?php
                            while ($result = $resultado->fetch_assoc()) {
                                ?>
                                <tr>
                                    <td><?php echo $result['id_order'] ?></td>
                                    <td><?php echo $result['num_factura'] ?></td>
                                    <td><?php echo $result['num_albaran'] ?></td>
                                    <td><?php echo $result['reference'] ?></td>
                                    <td><?php echo $result['customer'] ?></td>
                                    <td><?php echo $result['email'] ?></td>
                                    <td><?php echo $result['dni'] ?></td>
                                    <td><?php echo $result['group_name'] ?></td>
                                    <td><?php echo $result['BI'] ?></td>
                                    <td><?php echo $result['total_paid_real'] ?></td>
                                    <td><?php echo $result['RE'] ?></td>
                                    <td><?php echo $result['payment'] ?></td>
                                    <td><?php echo $result['date_add'] ?></td>

                                    <td>
                                        <?php
                                        if ($result['utm_source'] != NULL || $result['utm_source'] != "") {
                                            echo $result['utm_source'];
                                        } else {
                                            ?>
                                                <div style="width: 100px;">
                                                    <!--<form name="utm" action="" onSubmit="enviarDatosUTM(); return false" >
                                                        <input type="number" name="id_order" id="id_order" value="<?php echo $result['id_order'] ?>" style="display: none;" />
                                                        <input type="text" size="5px" name="utm_source" id="utm_source"/>
                                                        <input type="submit" value="&#10004;"/>
                                                    </form>-->
                                                    <input type="number" name="id_order" id="id_order" value="<?php echo $result['id_order'] ?>" style="display: none;"/>
                                                    <input type="text" size="5px" name="utm_source" id="utm_source" />
                                                    <input type="button" href="javascript:;" onclick="enviarDatosUTM($('#id_order').val(), $('#utm_source').val());
                                                                    return false;" value="&#10004;"/>
                                                           <?php
                                                   }
                                                   ?>
    
asked by Pau G.P. 23.09.2017 в 17:52
source

1 answer

1

The way to obtain the parent element through another is:

$("#elemento").closest("td");

Now, if you want to do something to that element, how to change the html would be something like this:

$("#elemento").closest("td").html('<input value="nuevoValor">');

Greetings. Here I leave the documentation

    
answered by 26.09.2017 в 18:59