Note that there are some explanatory texts on larger screens.

plurals
  1. POValidate ddslick drop down value was selected
    primarykey
    data
    text
    <p>I have a page I am working on which requires the value of a ddslick created drop down box be chosen in order to submit. The drop down is functioning, the value when selected passes to the target page which I am parsing the POST values with PHP. However, I am having a issue validating this ddslick drop down box. To make sure a value was chosen before submitting.</p> <p>Here is the select box that I have:</p> <pre><code>&lt;select name="backing" id="backing" class="ddslick-select"&gt; &lt;option value=""&gt;Select Back Style&lt;/option&gt; &lt;option value="red"&gt;Red&lt;/option&gt; &lt;option value="orange"&gt;Orange&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I am using this code to get the backing value:</p> <pre><code>&lt;script type="text/javascript"&gt; $('#backing').ddslick({ showSelectedHTML: false, onSelected: function(data){ alert(data.selectedData.value); } }); &lt;/script&gt; </code></pre> <p>When I submit it, the $_POST value of #backing is passing. However I am having a issue validating it to make sure a value was selected.</p> <p>In the form I have a submit button, and I validate the Quantity and the Back style via this onsubmit function:</p> <pre><code>&lt;a href="#" class="btn btn-cart right" onclick="javascript:return validateCart();"&gt;Add to cart&lt;/a&gt; </code></pre> <p>Here is the Javascript function, the Qty is validating but the drop down with ddslick is not. If I remove the class="ddslick-select" from the dropdown which turns it to a normal drop down box, the validation works fine.</p> <p>Here is Javascript function for ValidateCart():</p> <pre><code>function validateCart(){ var error = ""; if(document.getElementById("qty").value == '') { error += "You must select Quantity\n"; } if(document.getElementById("backing").value == '') { error += "You must select a Backing Design\n"; } if(error !== '') { alert(error); return false; } else { document.productorder.submit(); } } </code></pre> <p>My question is, how can I modify what I have now to validate the drop down box?</p> <p>Thanks!</p>
    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.
    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