Greetings,
Ok. I think there is a problem with my javascript. This script is suppose to create a spinning box. Can you please help me?
<script type="text/javascript">
// global variable to store position
var pos = 0;
// function to rotate a div with id of "d1"
function spin()
{
// get the div's style object
var obj_style = document.getElementById("d1").style;
// store desired radius and x,y offsets
var radius = 40;
var x_offset = 50;
var y_offset = 50;
// increment to the new position
pos += 10;
// use Math to calculate the new x.y coordinates
x = radius * Math.cos( pos * Math.PI/180 );
y = radius * Math.sin( pos * Math.PI/180 );
// add the x, y offsets
x += x_offset;
y += y_offset;
// move the div to its new coordinates
obj_style.left = x + "px";
obj_style.top = y + "px";
// set the interval to call the function again
setTimeout( "spin()",100 );
}
</script>
</head>
<body onload="spin()">
'
I had got this code / script from a JavaScript book... Can someone please help me with it. Thanks. 






bja888 posted this at 04:06 — 30th May 2005.
He has: 902 posts
Joined: Feb 2004
1) what error are u getting
2) try not to use free scripts
=cipher= posted this at 16:59 — 30th May 2005.
They have: 13 posts
Joined: May 2005
Greetings,
1. What error are you getting?
-- None. Nothing appears.
2. Try not to use free scripts.
-- I didnt. Well sort of, but I coded some of it by myself. I got it from a JavaScript book, (part of it) and I coded the rest.
Abhishek Reddy posted this at 18:51 — 30th May 2005.
He has: 3,303 posts
Joined: Jul 2001
Code works for me in Firefox. Had to add a d1 element myself, though.
What does your d1 element look like? What browser are you using?
abhishek.geek.nz
=cipher= posted this at 19:24 — 30th May 2005.
They have: 13 posts
Joined: May 2005
thats my problem i guess... what do i have to use for the d1 ?? can you tell me or help with this
:D Also, how would I just draw a plain simple red box ?? I would like to make that spin 
chrishirst posted this at 05:34 — 31st May 2005.
He has: 379 posts
Joined: Apr 2005
If you don't have an element with an id of "d1", nothing will happen because the script won't find anything to spin.
Chris
Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples
Abhishek Reddy posted this at 07:23 — 31st May 2005.
He has: 3,303 posts
Joined: Jul 2001
This is what I used to test it:
<div id="d1" style="position:absolute; left:100; top:100; width:100; height:100; border: 1px solid black"></div>'It's just a 100x100 div, positioned absolutely. You can use whatever you like... I can't really tell you what you want.
Just make sure it has id="d1".
abhishek.geek.nz