SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Php_penguin's Avatar
    Join Date
    Aug 2004
    Location
    Colwyn Bay, Wales, UK
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SetTimeout: expected )

    trying to send a loop function, but problems are arising with the setTimeout section of the function.

    here is the function:
    Code:
    function shrink(cbox,hei,fh,dire,resu) {
    	cont = "TRUE";
    	if(dire == "s") {
    		if(hei > 1) {
    			nhei = hei-30;
    			di = "s";
    		} else {
    			cbox.innerHTML = resu;
    			cbox.style.height="100%";
    			fh = cbox.offsetHeight;
    			cbox.style.height="0px";
    			di = "g";
    		}
    	} else {
    		if(hei < fh) {
    			nhei = hei+30;
    			di ="g";
    		} else {
    			cbox.style.height=fh;
    			di = "g";
    			cont = "FALSE";
    		}
    	}
    	if(cont=="TRUE") {
    		dome = cbox+",'"+nhei+"','"+fh+"','"+di+"',"+resu;
    		cbox.style.height=nhei+"px";
    		setTimeout("shrink("+dome+")",15);
    	}
    }
    as you can see it shrinks and then expands the box (something to do )

    however, at the timeout section, the error "Expected )" occurs (script works when that line is commented out)

    anyone had this problem before?

    please note that cbox is an object - fh and nhei are numerical strings, di and resu are strings, resu will likely contain large volumes of data and special characters.

    please help!! thanks in advance

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    settimeout

    The first argument for settimeout is in quotes, but you are using quotes to separate the variable. Maybe like this instead?
    Code:
    		setTimeout("shrink('"+dome+"')",15);

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or to avoid the JS engine to do an eval:
    Code:
    window.setTimeout(function()
    {
        shrink(dome);
    }, 15);


Bookmarks

Posting Permissions

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