Logic 4 table with editing options

I want to display the list as described in the link. http://imgur.com/3zeSd As soon as a value is selected in the drop-down menu. Then it should immediately save the value.

EDIT: -

The code I wrote that works ... This is in a loop.

    <tr>
    <td><?php $number += 1; echo $number;?></td>
    <td><?php echo $record['db1_CON_NUMBER'];?></td>
    <td><?php echo $record['DB1_status'];?></td>
    <td width="100" class="rtodata">
       <select name="action_db2" id=<?php echo $record['db1_CON_NUMBER']; ?>  onchange="mark_doubleones_1('doubleones1.php?tab=doubleones&id='+this.id+'&value='+this.value);">
            <option value=""<?php if( $action_db1 == '') echo 'SELECTED';?></option>
            <option value="yes"<?php if( $action_db2 == 'yes') echo 'SELECTED';?>>Ok to Invoice</option>
            <option value="no"<?php if( $action_db2 == 'no') echo 'SELECTED';?>>Exclude</option>
        </select>
    </td>
    </tr>

and in javascript

function mark_doubleones_1(url){
    document.location.href = url;
}

Now another method suggested by @mistabell,

<select name="action_db2" id=<?php echo $record['db1_CON_NUMBER']; ?>  onchange="updateItem(this)"> 

and the story below ...

0
source share
1 answer

It would be better to separate your javascript from the element on the page and avoid the onClick HTML link. Use this ...

jQuery('.rtodata select').bind('change', function (e) {
    jQuery.ajax({
        type: 'post',
        url: 'ajax-file.php',
        data: {
            value: jQuery('select option:selected', jQuery(e.currentTarget).parent()).val()
        },
        success: function (r) {
            alert('success');
        },
        error: function (error, t, msg) {
            alert('failed');
        }
    });
}

ajax-file.php $_POST. - HTML , onClick="....", HTML, .

+1

Source: https://habr.com/ru/post/1774098/


All Articles