Home > DeveloperSection > Forums > getelementbyid has no method using javascript
Ashish Pandey

Total Post:128

Posted on    August-19-2013 12:49 AM

 JavaScript JavaScript 

 1 Reply(s)
 1227  View(s)
Rate this:
Hi Minsdstick!

I have a pull down menu, what i would like is that when there is a change with the pull down that a <div> displays that was previously hidden. But I keep getting an error of:

uncaught typerror:object #<HTML Document> has no method 'getElementByID'

Here is the code:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

   <html xmlns="http://www.w3.org/1999/xhtml">



   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

function showdiv() {

document.getElementByID("DIV1").style.display = "inline-block";




<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

      <select id="awf_field-28500717" name="custom Country" tabindex="503" onChange="showdiv()">

        <option class="multiChoice" value="United States">United States</option>

        <option class="multiChoice" value="Canada">Canada</option>

        <option class="multiChoice" value="United Kingdom">United Kingdom</option>

        <option class="multiChoice" value="Australia">Australia</option>

        <option selected>Select</option>


    <div id="DIV1" name="DIV1" style="display:none;">





Thanks in advance

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-19-2013 8:32 AM


You have getElementByID while the actual method is getElementById 

<script type="text/javascript">

  function showdiv() {

    document.getElementById("DIV1").style.display = "inline-block";



Don't want to miss updates? Please click the below button!

Follow MindStick