Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error when I use getElementsById.display

Posted on 2007-11-21
9
Medium Priority
?
930 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

885 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