Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    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

  • Users who have thanked DanInMa for this post:

    NorbNYC (11-11-2012)

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Yup it was my mistake, numbertohide wasn't actually coming out to 2.

    Thanks Dan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •