Solved

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

Posted on 2011-02-28
7
290 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

785 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