Solved

Issue with Javascript Code

Posted on 2013-12-06
4
255 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
Question by:myselfrandhawa
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 15

Author Comment

by:myselfrandhawa
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

Highfive Gives IT Their Time Back

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

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
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 how to dynamically set the form action using jQuery.
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…

707 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

15 Experts available now in Live!

Get 1:1 Help Now