Solved

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

Posted on 2011-02-28
7
294 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

828 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