0
<select name="optionSnoInput" class="chosen-select" onchange="goodsViewController.option_price_display(this);">
    <option value="">option</option>
    <option value="104">A</option>
    <option value="105">B</option>
    <option value="106">C</option>
    <option value="107">D</option>
    <option value="108">count</option>
</select>

On the above dropdown, I want last option 'count' is automatically selected because I need counting each product's selling Quantity

but my shop program is counting Quantity as option not product

so I add 'count' option, and use 'display:none' css code..

Please suggest!

Thanks.

1
  • Add selected attribute to the last option tag. Commented Apr 21, 2020 at 5:23

2 Answers 2

1

You can do it with JQuery this way to:

$(window).on('load', function(){
  $('.chosen-select option:last-child').attr('selected','selected');
})

$(window).on('load', function(){
  $('.chosen-select option:last-child').attr('selected','selected');
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="optionSnoInput" class="chosen-select" onchange="goodsViewController.option_price_display(this);">
    <option value="">option</option>
    <option value="104">A</option>
    <option value="105">B</option>
    <option value="106">C</option>
    <option value="107">D</option>
    <option value="108">count</option>
</select>

Sign up to request clarification or add additional context in comments.

Comments

0

Use selected for the default option.

<option value="108" selected>count</option>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.