<a href="#" data-target="#edit-order value="<?php echo $users[$i]['id']; ?>" name="delete-order" id="bb-confirm" data-placement="left" data-rel="tooltip" data-toggle="modal" data-original-title="Delete Order" class="btn btn-danger"><i class="fa fa-times icon-only"></i></a>
I want to parse the "value" info to this edit-order form and i didn't manage to make it work. I've tried with GET but nothing.
<div class="modal fade modal-scroll" id="edit-order" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus-circle"></i> Add Order</h4>
</div>
<div class="modal-body padding-2x">
<form role="form" method="post">
<div class="form-group">
<label>Order ID #</label>
<?php echo ORDER-ID-PASSED-FROM-BUTTON; ?>
</div>
<div class="form-actions no-padding-bottom">
<div class="btn-group">
<button type="submit" name="edit-order" class="btn btn-primary">Update Order</button>
</div>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Can somebody help me with this ? Thanks a lot
If your modal dialog stay in the DOM you can use this code:
var links = document.querySelectorAll('[data-target="#edit-order"]');
[].forEach.call(links, function(link) {
link.onclick = function() {
var value = link.getAttribute('value');
var group = document.querySelector('.modal form .form-group');
var input = document.querySelector('.modal form .form-group input');
if (input) {
group.removeChild(input);
}
input = document.createElement('input');
input.setAttribute('value', value);
input.setAttribute('name', 'order');
group.appendChild(input);
};
});
or using jQuery:
$('[data-target="#edit-order"]').click(function() {
$('.modal form .form-group input').remove();
var value = $(this).attr('value');
$('.modal form .form-group').append('<input name="order" value="' + value + '"/>');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.