php - Input | Get the new value set by a JavaScript function into a Controller public function
Get the solution ↓↓↓Solution:
When you have a default value forinput
field, changing it viaval()
wouldn't impact it.
You need to useattr()
, so instead of lines like:
$('#ordersdetailproductprice').val('0.00');
Use:
$('#ordersdetailproductprice').attr('value', '0.00');
And then you can easily fetch the input value to send to your Controller (via AJAX I believe) as:
let value = $('#ordersdetailproductprice').val();
I hope it helps you
Answer
Solution:
SOLUTION AJAX CALL IN JS SCRIPT :
...
else if (d1 == 4 && d2 == 27 && d3 == '' && pl1 == 2 && pl2 == 2) { $('#productprice').val('59.00'); }
else if (d1 == 4 && d2 == 27 && d3 == '' && pl1 == 3 && pl2 == 3) { $('#productprice').val('69.00'); }
else if (d1 == 4 && d2 == 27 && d3 == '' && pl1 == 4 && pl2 == 4) { $('#productprice').val('79.00'); }
else if (d1 == 4 && d2 == 27 && d3 == '' && pl1 == 4 && pl2 == 5) { $('#productprice').val('89.00'); }
var rowID = rowid;
var orderID = $('#orderID').val();
var productprice_new = $('#productprice').val();
console.log(productprice_new,rowID,orderID);
$.ajax({
type: 'post',
url: '/assets/ajax/ajaxupdate.php',
data: {
'rowid' : rowid,
'orderID' : orderID,
'productprice_new' : productprice_new,
},
success: function (data) {
console.log('worked!');
},
error: function (data) {
console.log('Error:', data);
}
})
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: npm err! code 1
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.