Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-11-2012, 01:29 AM   PM User | #1
NorbNYC
New to the CF scene

 
Join Date: Aug 2012
Posts: 9
Thanks: 4
Thanked 0 Times in 0 Posts
NorbNYC is an unknown quantity at this point
variable valuation in the for statement

Hi folks.

I know numbertohide = 2.

How come
Code:
				for (var h=numbertohide;h<6;h++)
					{
					
					inputselectionelementid = '#inputselection' + h;					
					$(inputselectionelementid).hide();
					console.log('hide ' + inputselectionelementid);
					}
does not work? Only var h=2 directly properly executes the loop.

Thanks
NorbNYC is offline   Reply With Quote
Old 11-11-2012, 02:46 AM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
not sure why, bt they way you've formed your code, I can tell you theres probably an easier way to do what you are doing, since you are apparently using jQuery.

Would you mind showing some more, maybe we can help you reach your overall goal a little better?


- loop looks fine to me, most likely answer is that numbertohide isnt coming to 2, like you think it is
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Users who have thanked DanInMa for this post:
NorbNYC (11-11-2012)
Old 11-11-2012, 01:35 PM   PM User | #3
NorbNYC
New to the CF scene

 
Join Date: Aug 2012
Posts: 9
Thanks: 4
Thanked 0 Times in 0 Posts
NorbNYC is an unknown quantity at this point
Yup it was my mistake, numbertohide wasn't actually coming out to 2.

Thanks Dan
NorbNYC is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:26 PM.


Advertisement
Log in to turn off these ads.