Solved

Error when I use getElementsById.display

Posted on 2007-11-21
9
922 Views
Last Modified: 2013-11-19
Hello Everyone,
       
I want the US states drop down menu to appear only when the country that is selected is: United States

  Originally I got the following JavaScript pop up error:

                    document.getElementsById(...).display' is null or not an object

And it was coming from the following line:

                     document.getElementsById("allstate").disply.style="block";


But after I changed the code to:
                               document.getElementsById("allstate").disply="block";
the error went away...

However, I still cannot see the state row, so I can select a state now that the country is the United States, so I still need your help with this question!!

Can you help me?  I bet I'm missing something... synthax error... maybe...



Here is my code:

<form action="115-002.asp" id="OPICForm" name="OPICForm" method="post" onSubmit = "return validateSubmit();" >

<table>
      <TR id = "allstate" style="display:none;">
            <TD class="number">&nbsp;</TD>
        <TD class="question">State:<font color="#FF0000">*</font></TD>
                  <TD class="response"> <select name="AuthorizedRepState" id="AuthorizedRepState" style="font-family: Verdana; font-size: 8pt">
          <% showStates sAuthorizedRepState %>
        </select></TD>
      </TR>
      <TR>
            <TD class="number">&nbsp;</TD><TD class="question">Country:<font color="#FF0000">*</font></TD>      <TD class="response">
            <select name="AuthorizedRepCountry" id="AuthorizedRepCountry" style="font-family: Verdana; font-size: 8pt" onChange="ShowAllStates();">
            <% showCountries sAuthorizedRepCountry %>
            </select>
            </TD>
      </TR>
</table>

<script>
   //Angie H. 11/21/07 -- By using onChange() javascript event you can show the "allstate" div when the value equal to US
      function ShowAllStates(){
            if(document.OPICForm.AuthorizedRepCountry.value =="United States")
            {
            document.getElementsById("allstate").disply.style="block";
            }
      }      
</script>

What do you think, what am I doing wrong?  


0
Comment
Question by:Gemini532
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 18

Expert Comment

by:Morcalavin
ID: 20328327
There is no getElementsById function.  You want:
document.getElementById

Open in new window

0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 20328337
And it should be:

document.getElementById(id).style.display = 'block';

Open in new window

0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20328396
It should be like

document.getElementsById("allstate").style.disply="block";
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Gemini532
ID: 20331015
I changed the function to:

   //Angie H. 11/21/07 -- By using onChange() javascript event you can show the "allstate" div when the value equal to US
      function ShowAllStates(){
            if(document.OPICForm.AuthorizedRepCountry.value =="United States")
            {
            document.getElementById("allstate").style.disply="block";
            //document.getElementsById("allstate").style.disply="block";
            }
      }
but I still do not see the STATES DISPLAYING ON THE SCREEN!!!

Something else must be wrong... can you help me find out what?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20331359
Try:
document.getElementById("allstate").style.disply="inline";
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20331366
dam i just realized u (also I) spelt display wrong!

document.getElementById("allstate").style.display="block";

or

document.getElementById("allstate").style.display="inline";

one of them should work, if not both.
0
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
ID: 20333344
spelling mistake for display.
document.getElementById("allstate").style.display="block";
0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 20354238
Not that I'm one to complain, but two other people answered the question correctly before the accepted answer, so why not, at the very least, a point split?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20355596
hmm interesting point allocation. may I ask why not a point split @ least to Morcalavin, who was actually the first to pick up the spelling mistake way before the other posts?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question