?
Solved

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

Posted on 2011-02-28
7
Medium Priority
?
303 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:Gurvinder Pal Singh
ID: 34996878
what is <<form1.issubscription.value>>??
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 800 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 1200 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:Gurvinder Pal Singh
Gurvinder Pal Singh earned 800 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Suggested Courses

752 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