Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1931
  • Last Modified:

Show DIV based on onSelect event handler

I'm trying to show and hide DIVs based on the onSelect event handler, but it's not working.

This is my javascript:

function showDiv(divID) {
document.getElementById(divID).style.display = 'block';

And this is my HTML:

Type of payment account:
      <select name="paymentAccountType" onchange="showDiv(this);" >
      <option>Credit card</option>
      <option>Debit card</option>

<div id="EFT" style="display:none;">EFT</div>
<div id="credit" style="display:none;">Credit card</div>
<div id="debit" style="display:none;">Debit card</div>
1 Solution

Change your select box to this:

Type of payment account:
     <select name="paymentAccountType" onchange="showDiv(this.value);" >
     <option value="credit">Credit card</option>
     <option value="debit">Debit card</option>
     <option value="eft">EFT</option>

That should work!

Let me know if you need anything else

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now