• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Issue with Javascript Code

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
Gurpreet Singh Randhawa
Asked:
Gurpreet Singh Randhawa
1 Solution
 
Alexandre SimõesManager / Technology SpecialistCommented:
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
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
it is used for noconflict with other libraries
0
 
leakim971PluritechnicianCommented:
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
 
Sar1973Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now