Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to replace value if is empty Jquery
    primarykey
    data
    text
    <p>I have a question about jquery changing value on select from dropdown.</p> <p>This jquery is based on magento Simple Configurable Product extension.</p> <p>This is the source:</p> <pre><code>$childProducts[$productId]["productDate"] = $product-&gt;getAttributeText('preorderdate'); </code></pre> <p>Return <code>var spConfig = new Product.Config({"productDate":"","productDate":"November 2013"})</code></p> <p>Jquery to change div text on select.</p> <pre><code>Product.Config.prototype.updateProductDate = function(productId) { var productDate = this.config.productDate; if (productId &amp;&amp; this.config.childProducts[productId].productDate) { productDate = this.config.childProducts[productId].productDate; } // if(productDate.lenght === 0) if(productDate === ''){ $$('p.availability.in-stock span').each(function(el) { el.innerHTML = 'Is in stock'; }) $$('p.availability.in-stock span').each(function(el) { el.innerHTML = productDate; }); }; </code></pre> <p>The issue is that on select the option with no value is still showing the blank value and not returning <code>el.innerHTML = 'Is in stock';</code> .</p> <p>Where is wrong?</p> <p>Any help is appreciated.</p> <p>Found solution by myself, brackets not in your place.</p> <pre><code> Product.Config.prototype.updateProductDate = function(productId) { var productDate = this.config.productDate; if (productId &amp;&amp; this.config.childProducts[productId].productDate) { productDate = this.config.childProducts[productId].productDate; } $$('p.availability.in-stock span').each(function(el) { el.innerHTML = productDate; }); if(productDate === ''){ $$('p.availability.in-stock span').each(function(el) { el.innerHTML = 'This is in stock'; }); } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload