logo
down
shadow

Get data from data-price using jquery


Get data from data-price using jquery

By : user2954833
Date : November 22 2020, 10:33 AM
hop of those help? You have to use data method to get data-price attribute
code :
$('[name="category"]:checked').data('price')


Share : facebook icon twitter icon
Jquery select all checked checkboxs with data-price and add them together

Jquery select all checked checkboxs with data-price and add them together


By : Silence Wang
Date : March 29 2020, 07:55 AM
will be helpful for those in need There are several logic problems with your example, leading to an endless price increase when you change items, an incorrect cost for the selected options on page load and also issues when more than one block of options is used.
First of all, add a class to each input that needs to be included in the pricing total, I used calculation-item in my example. The removes the need for the * selector which is overkill for what you need and also slow.
code :
var base_price = 300;
CalculatePrice();

$(".calculation-item").click(function() {
    CalculatePrice();
});


function CalculatePrice() {
    var base_cost = base_price;
    $(".calculation-item:checked").each(function(index) {
        base_cost += $(this).data("price");
    });

    $("#final_price").html(base_cost);   
}
Magento: Revert price data from index. False price data saved, but not indexed

Magento: Revert price data from index. False price data saved, but not indexed


By : Shinsuke Kuroki
Date : March 29 2020, 07:55 AM
Hope that helps If you browse the database, there should be a catalog_product_flat_1 table - this is basically your product index. You should have columns for all the product attributes (including SKU and Price) so you could export this table, then do a product export from Magento, then update all the prices/SKUs accordingly and re-import. Or duplicate the flat_1 table, then write a PHP script to loop through it, updating all the prices, then re-index your data (after checking it's worked of course!)
Get data-price jquery

Get data-price jquery


By : Sohaib Raoufi
Date : March 29 2020, 07:55 AM
To fix the issue you can do Target the ID of the images, and attach an event handler, then on click, get the data attribute with data()
code :
$('#1, #2').on('click', function() {
    alert( $(this).data('price') );
});
$('#1, #2').on('click', function() {
    var data1 = parseInt( $('#1').data('price') ,10);
    var data2 = parseInt( $('#2').data('price') ,10);

    $('#sum').text(data1 + data2);
});
sum all data-price from input with attribute available in jquery

sum all data-price from input with attribute available in jquery


By : AlexMeah
Date : March 29 2020, 07:55 AM
should help you out The issue is because the first input has no data-price attribute, therefore undefined is returned and causes an error in the calculation.
To fix this you can coerce a null/missing value to 0 before you add it to the sum:
code :
$("#sub").click(function() {
  var sum = 0;
  $('#form input').each(function() {
    sum += $(this).data('price') || 0; // note the change on this line
  });
  console.log(sum);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form">
  <input type="hidden" name="make" value="0">
  <input type="hidden" name="got" value="" data-price='10'>
  <input type="hidden" name="get" value="" data-price='20'>
  <button id="sub">submit</button>
</form>
through Ajax price data comes to form input text, but not the selected product's price, instead only the firrst price is

through Ajax price data comes to form input text, but not the selected product's price, instead only the firrst price is


By : user3253306
Date : March 29 2020, 07:55 AM
Any of those help I have prepared a Sales recording form whereby you first select the product/stock_name. Once this selection is made it should populate a field called unit_selling price below with that product's/stock's price that should be fetched from the stock table in DB. This, happens partly since the the price of the first stock/product is fetched and only appears in the browser console. Help me fetch the specific product's price and make it appear in the form not only console. I have attached a DB pic. , You need to try the following code.
In the route file( web.php )
code :
Route::any('sales-price/getunitsellingprice/{stock_id}','SalesController@getUnitSellingPrice');
public function getUnitSellingPrice(Request $request, $stock_id)
{

   $stock = Stock::where('stock_id', $stock_id)->first();
   if ($stock == null) {
      return null;
   }

   return response()->json($stock->unit_selling_price);
}
<div class="form-group">
    <label>Product Name</label>
    <select name="product_name" class="form-control" id="stock_name">
    <option>Select Product Name</option>
        @foreach ($stocks as $stock)
        <option value="{{ $stock->stock_id }}">{{ $stock->stock_name}}</option>
        @endforeach
    </select>
</div>

<script>
$(document).ready(function () {
    $("#stock_name").on('change', function () {
    var stock_id = $(this).val();       
        $.ajax({
            //url: MyAppUrlSettings.MyUsefulUrl,
            url: '/sales-price/getunitsellingprice/'+stock_id,
            method: 'GET',              
            success: function (response) {
            console.log(response);
            $("#unit_selling_price").val(response);
            },
        });
    });
});
</script>
Related Posts Related Posts :
  • React | Can´t load Images > Module not found
  • Dynamically creating buttons in DOJO
  • 404 Not Found in AJAX post call
  • How do I find out, using javascript, what software opened and running my application?
  • Javascript to check the status of wireless connection
  • StarDict support for JavaScript and a Firefox OS App
  • Phonegap event Resume
  • call javascript function on ENTER key press?
  • When is the best time to remove no-js classes from the html tag
  • Recommended email sending languages
  • setInterval not working properly with chrome
  • Does IE create new scope for each script tag?
  • Uncaught SyntaxError: Unexpected token < Underscore and parse issues
  • How to pass captured URL to Email Body in HTML
  • How to structure default nested resources?
  • Store all the keys of a JSON object in a variable
  • Need an efficient way to group the Array of object in javascript
  • a sensible approach to highcharts x-axis labels
  • IDE autocompletion for javascript AMD loading style
  • Bootstrap menu disappears after first click setting the ul style to none
  • split ajax json response errors in each field
  • how to add javascript in head in cmsms
  • REGEX: Finding the correct occurrence order of some given special characters in a string
  • How do you preserve a JavaScript date's time zone from browser to server, and back?
  • Return binary result from phantomjs webserver
  • must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
  • Replacing a substring of an element's text with another string
  • How do I filter marks greater than or equal to 90 in this array?
  • Modify the text of my radio input button?
  • Clicking on status bar does not scroll to top of app (Trigger.io)
  • Mocha JS: How to highlight specific assertion failure?
  • $.getJSON jquery parsing to HTML
  • Find items of a certain class (a) that are also in other classes (b,c,d)
  • Setting different images for D3 force-directed layout nodes
  • Integrating Dropzone.js with angular
  • Control sprite animation speed
  • Can only one error / success function be assigned for AngularJS $http promises?
  • Working with math in javascript
  • Django variable isnt recognized by javascript
  • $.when does not work with $.scrollTo plugin
  • How to read local xml file using $.ajax?
  • Manifest is not Valid JSON. What is wrong?
  • AngularJS re-initialise JS after statechange
  • WebRupee is not working
  • How can I make the jQuery MultiSelect widget read-only?
  • How to associate javascript code with dom elements?
  • How to remove track from MediaStream and "stop" webcam?
  • clearvalidators not working in angular 6 form control
  • Remove Count Attribute in json data
  • queue up function callbacks
  • How to stop all Soundcloud streams in once?
  • Sliding div onclick left/right
  • RequireJS JQuery shim doesnt work with VS2013
  • What is the Meteor concurrency model?
  • Events on children of contenteditable element
  • Simple jquery not working to print the input value
  • Javascript templating language in reverse
  • Making Pagination in Javascript Scalable (for large # of db results)
  • Performance of Stateless Authentication in SPA and SSO (Single Sign On)
  • Assigning a value for view asynchronously
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org