?
Solved

Issue with Javascript Code

Posted on 2013-12-06
4
Medium Priority
?
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

649 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