Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • deeppatel 25 posts 95 karma points
    Jul 06, 2017 @ 13:12
    deeppatel
    0

    Replace Dropdown list to <ul> tag

    right now my site use dropdown list for select product size but now i want to change it like(below screen shot)

    Dropdown code:

        <select name="variation-size" id="variation-size" class="variant">
     <option value="">Select size</option>
    @foreach (var variant in product.Variants)
    {
    
    <option value="">Select size</option>
    @foreach (var variant in product.Variants)
    {
    int variantStock = 0;
    bool stockcheckSucces = int.TryParse(variant.GetProperty("InventoryOnHand").GetValue().ToString(), out variantStock);
    string value = variant.GetProperty("Size").GetValue().ToString();
    if (variantStock > 0)
    {
    <option value="@value">@value</option>
    }
    else
    {
    <option disabled value="@value">@value</option>
    }
    }
    </select>
    

    ul li code:

    <div class="col-xs-12">
    <ul class="variant" id="variation-size" name="variation-size">
    @foreach (var variant in product.Variants)
    {
    int variantStock = 0;
    bool stockcheckSucces = int.TryParse(variant.GetProperty("InventoryOnHand").GetValue().ToString(), out variantStock);
    string value = variant.GetProperty("Size").GetValue().ToString();
    if (variantStock > 0)
    {
    <li><a href="#">@value</a></li>
    }
    else
    {
    <li><a href="#">@value</a></li>
    }
    }
    </ul>
    </div>
    

    in dropdown when i select size then it stored in "variation-size" id but in

    • when i select size then it's pass null value. i mean not selected.

      i have get "variation-size" value using javascript function for dropdown.

      so any one know how i can do this or any other way without use

      • .

        thanks in advance.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jul 07, 2017 @ 13:49
    Alex Skrypnyk
    0

    Hi deeppatel

    What js framework are you using for getting the value?

    jQuery, angular?

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft