Solved

Javascript question for Use W3C standard document.getElementById() instead -2

Posted on 2011-02-28
7
298 Views
Last Modified: 2012-05-11
Hello eperts.
For the following script i get a message in firebug:

document.form1.sku.focus();
 
        if(form1.issubscription.value == 'yes') {
            document.getElementById("subscriptionfields").style.display = "block";
            }
      else
      {
            document.getElementById("subscriptionfields").style.display = "None";
      }
Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.

Any help?
0
Comment
Question by:Panos
[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
7 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34996878
what is <<form1.issubscription.value>>??
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 200 total points
ID: 34996888
i guess it is trying to say that rather than using names like "'issubscription", "sku", or "form1", use the id values and access the element using document.getElementById()
0
 
LVL 2

Author Comment

by:Panos
ID: 34996993
Hi.
Can you please the write the correct syntax.
form1 is the id of the form and sku , issubscription are formfields
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 300 total points
ID: 34997041
document.getElementById("sku").focus();
 
        if(document.getElementById("issubscription").value == 'yes') {
            document.getElementById("subscriptionfields").style.display = "block";
            }
      else
      {
            document.getElementById("subscriptionfields").style.display = "None";
      }
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 200 total points
ID: 34997063
<<sku , issubscription are formfields>>
are they id values or name attribute values?
check that and make them as per the id value
0
 
LVL 2

Author Comment

by:Panos
ID: 34997180
Ok.
I fixed it.I did use the code from chaituu but i add an id to the issubscription field because there was  only the name of the tag.

0
 
LVL 2

Author Closing Comment

by:Panos
ID: 34997188
Thank you.
regards
panos
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 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