SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    setting Initial Variables.

    I want to get intial top and left positions and save them for when the function is called again with the same object. I need the bits between the ??
    Any suggestions on how to go about it.

    Code:
    function doFun(Obj,var) {
    if(! ??Obj been through function?? ) { 
    setInitialVars(Obj);
    ??record Obj been through function??  } else {
    getInitialVars(Obj); }
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    IntObjs="";
    IntObjsTop=new Array;
    IntObjsLeft=new Array;
    function doFun(Obj,var) {
    tObj=document.getElementById(Obj);
    if(IntObjs.indexOf(Obj)<0) { 
    IntObjs+=Obj; 
    IntObjsTop[IntObjs.indexOf(Obj)]=parseInt(tObj.style.top)
    IntObjsLeft[IntObjs.indexOf(Obj)+1]=parseInt(tObj.style.left)
    }
    }
    Found this worked, but if there's better could you let me know. Thanks
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function doFun(Obj,var)
    {
    	if( !Obj.processed )
    	{ 
    		setInitialVars(Obj);
    		Obj.processed = true;
    	} else {
    		getInitialVars(Obj);
    	}
    }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Can I assign variables in a similar way?

    been trying
    Code:
    if( !Obj.intTop ){ 
    Obj.intTop=parseInt(tObj.style.top);
    Obj.intLeft=parseInt(tObj.style.left);
    }
    doesn't seem to work
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •