-1

I have run in to a stupid problem... I declared a new variable called leadingZero. I save the modified .js file and run the project with a breakpoint on the leadingZero assignment and in watcher window it says its undefined after passing this line, but all the other declarations here are working fine and I can see the assigned values. needless to say the getObject call does not work now.

var leadingZero = 0; //new variable
var chkActive; 
var chkSubscribe; 
var hdnItem = getObject('hdnItemCounter');
var ItemCount = parseInt(hdnItem.value) + 1;

for (intCounter = 2; intCounter <= ItemCount; intCounter++) {
  chkActive = getObject('dgrProductList_ctl0' + leadingZero + intCounter + '_chkActive');
}
2
  • It's defined every time I run your code subbing in a noop for getObject Commented Apr 13, 2012 at 11:47
  • 1
    When presenting JavaScript issues a working sample on jsfiddle.net as well as indicating platform and browser make debugging and answering a whole lot easier :) Commented Apr 13, 2012 at 11:50

3 Answers 3

2

Check this http://jsfiddle.net/DHDsE/

Not getting the undefined problem tho, but having to add toString() to leadingZero for it to render in the console.log, so maybe that's your issue too.

Sign up to request clarification or add additional context in comments.

1 Comment

i can use this piece you provided var hdnItem = { value: 3 };
1

You did set the breakpoint on the line below, didn't you?

Because if you set it on the line var leadingZero = 0; it halts before the line is evaluated, which explains the undefined value in the watcher.

Also, as gillesc pointed out, your leadingZero must be a string, otherwise you're adding up intCounter and leadingZero, rather than concatenating them.

Comments

0

The problem seemed to be changes to the js were not loaded in ie cache. even after closing ie, rebuilding the project and running again, I still need to hit ctrl+f5 on the page to load the new javascript

1 Comment

The question should have mentioned that the problem was only appearing in IE then, just like Marc Gagne commented and this should have been added as a comment not as an answer. But hopefully now you know to always kill that cache before looking for bugs :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.