Solved

Issue with Javascript Code

Posted on 2013-12-06
4
259 Views
Last Modified: 2013-12-20
I have the following function which works in all browsers except in IE7 mode

I always check with developer tools and it shows error on the following function:

function inspectFields() {
		if (document.shippingForm.checkService != undefined) {	
			document.shippingForm.getElementById('checkService').checked = true;
		$j('#Addr').hide();
		
	}	
}

Open in new window


Display error on this line:

document.shippingForm.getElementById('checkService').checked = true;

object doesn't support this property

how will i write above in jquery to see if that fixes the issue

it is called as the following

addLoadEvent(inspectFields);

Open in new window

0
Comment
4 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39700833
In the code I see: $j('#Addr').hide();

What's $j ? A syntax error or something else?

For me that line should normally be: $('#Addr').hide();
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39700888
it is used for noconflict with other libraries
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39700891
Replace : document.shippingForm.getElementById('checkService').checked = true;
By : $('#checkService').attr("checked", true); // please confirm your jQuery version

Or if did not follow the rule << ID attribute MUST be unique in a page >> :

$("#checkService", "form[name=shippingForm]").attr("checked", true);
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 39704306
I'm not sure that JS getElementById allows a double declaration such as document.shippingForm.getElementById('checkService')
Shouldn't it be simply document.getElementById('checkService')...?
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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

820 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