Solved

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

Posted on 2011-02-28
7
285 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now