vForums Support > Programming & Coding :: Code Requests & Support :: > Reposition Element

Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 5:21pm
Code:
 
  1. <script>
  2. function RePos(WinID,X,Y){
  3. get(WinID,'id').style.top = Y;
  4. get(WinID,'id').style.left = X;
  5. }
  6. </script>
 


I call it using onclick="RePos('the-id',50,50);"

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 5:49pm
You'd need to give the element some form of positioning - absolute or fixed etc... {Smile}

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 6:10pm
It has fixed

Re: Reposition Element - Posted By dog199200 (dog199200) on 11th Jan 10 at 6:25pm
i'm assume by the positioning is in the onclick feature?

the 50,50 ?

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 6:28pm
 
It has fixed

Is it working?

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 6:37pm
The code isn't

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 6:45pm
What's the forum link so that I can take a look. {Smile}

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 6:50pm
The Final Anime Hideout (In my sig)

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 7:09pm
You don't actually need the code that you have in there at the moment from the looks of it,it doesn't do anything! O.o

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 7:10pm
I have a code that makes some spans draggable, I want this code to move them back

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 7:20pm
Code:
 
  1. <script>
  2. function RePos(WinID,X,Y){
  3.      get(WinID,'id').style.top = Y;
  4.      get(WinID,'id').style.left = X;
  5. }
  6. </script>
  7.  
  8. <div id = 'x' onclick = "RePos('x', '500px', '500px');" style = 'position: fixed; padding: 50px; border: 1px solid #000000; background: #800000; color: #FFFFFF;'>
  9. This is a repositionable box!
  10. </div>
 



That code works fine. {Smile}

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 7:23pm
Maybe I just called it wrong

Edit: Yep, I did call it wrong with the X and Y, works now

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 7:25pm
You'll need to include the 'numberpx' in it. Without the px declaration it won't recognise what you want to do. At least my testing revealed that. You can either throw it into the function, or the call. {Smile}

Re: Reposition Element - Posted By Aiken (ionfortuna) on 11th Jan 10 at 8:02pm
It works really good now

Re: Reposition Element - Posted By Michael (wrighty) on 11th Jan 10 at 8:08pm
Good to know! {Smile}