jQuery Help - On Change of Select show div

<select class="form-control" name="assetType" required="" style="padding:0;">
                                <option value="" disabled="">---</option>
                                                                    <option value="1">TEXT</option>
                                                                        <option value="2">VIDEO</option>
                                                                        <option value="3">IMAGE</option>
                                                                        <option value="4">BILLBOARD</option>
                                                                        <option value="5">BANNER</option>
                                                                        <option value="6">OTHER</option>
                                                                </select>

Open in new window


How can I look for a change event of the dropdown and show a div only if the "VIDEO" selection is selected?
LVL 12
Nathan RileyFounderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
This should do it
<!doctype html>
<html>
<head>
<title>Q_28680506</title>
</head>
<body>
<select class="form-control" name="assetType" required="" style="padding:0;">
  <option value="" disabled="">---</option>
  <option value="1">TEXT</option>
  <option value="2">VIDEO</option>
  <option value="3">IMAGE</option>
  <option value="4">BILLBOARD</option>
  <option value="5">BANNER</option>
  <option value="6">OTHER</option>
</select>
<div id="showme" style="display: none">Boo</div>
                                  
<script src="http://code.jquery.com/jquery.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
$(function() {
  $('select[name="assetType"]').change(function() {
    if ($(this).val() ==  2)
    {
      $('#showme').show();
    }
    else {
      $('#showme').hide();
    }
  });
});
</script>
</body>
</html>

Open in new window

Sample here http://www.marcorpsa.com/ee/t783.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
If you want to select on the actual text of the option then replace line 25 with
    if ($('option:selected', this).text() ==  'VIDEO')

Open in new window

Rainer JeschorCommented:
Hi,
this should do the trick:
$("select[name='assetType']").change(function() {
	if ($(this).val() == 2) {
		$("#YourdDIVid").show();
	}
});

Open in new window

HTH
Rainer
Rainer JeschorCommented:
Please ignore my double posting - Julians answer is the one you should choose (too late 4 me :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.