NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Javascript question

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-26-2006, 06:42 PM THREAD STARTER               #1 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Javascript question


I would like to draw a spiral of words on-screen. Example: I want the word "Hi" to appear in a spiral, multiple times.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 07:58 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Code:
function spiral() {
	document.getElementById('spiral').style.top = (Math.sin(i)*10);
	document.getElementById('spiral').style.left = (Math.cos(i)*10);
	i += 1;
	setTimeout('spiral()',50)
}
That's the best I could do :x
Dan is offline  
Old 12-26-2006, 08:09 PM THREAD STARTER               #3 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Nope. Here is your code in action:

http://discussingtech.com/spiral.html
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 08:16 PM   #4 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Code:
<div id="spiral" style="position: absolute; top: 0; padding-left: 30px;">yo</div>
<script type="text/javascript">
var i = 0;
function spiral() {
	document.getElementById('spiral').style.top = (Math.sin(i)*10);
	document.getElementById('spiral').style.left = (Math.cos(i)*10);
	i += 1;
	setTimeout('spiral()',50)
}

window.onload = function () { spiral(); }
</script>
Dan is offline  
Old 12-26-2006, 08:39 PM THREAD STARTER               #5 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Works. So far.

The problem is that I dont want the previous one to disappear when the next one is drawn.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 08:42 PM   #6 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Previous what and next what? :X
Dan is offline  
Old 12-26-2006, 08:45 PM THREAD STARTER               #7 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Your script makes the dancing word. I dont want it to dance, I want it to create a spiral. In other words, I want the text/images to stay still once it is generated.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 08:59 PM   #8 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Can you explain what you want?

You are saying barely anything and when I do what you ask for, there's a whole new part of something you want it to do that you've never said before.
Dan is offline  
Old 12-26-2006, 09:04 PM THREAD STARTER               #9 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Im trying to explain this...its a bit difficult to explain. Im sorry if it was phrased wrong before.

Your code, shown in action here, has the word 'yo' move around in what appears to be a spiral. However, your code is written so that the actual div moves. What I need is something that can create another <div> with this new positioning, and do that multiple times, so that the word 'yo' does not disappear every time.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 11:21 PM THREAD STARTER               #10 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




I think I almost have it

Here is the code I have, the result can be viewed at http://www.domainrealty.info/forum/spiral.html

Code:
<center><div id="spiral0" style="position: absolute; top: 0; padding-left: 300px; padding-top: 300px;"><div id="contain"></div>yo</div></center>
<script type="text/javascript">
var i = 0;
var divs = new Array();
var x = 0;
function spiral() {
	for(x = 0;x <= divs.length;x++) {
		document.getElementById('spiral'+x).style.top = (Math.sin(divs[x])*100);
		document.getElementById('spiral'+x).style.left = (Math.cos(divs[x])*100);
	}
	y = x + 1;
	document.getElementById('contain').innerHTML += '<div id="spiral'+y+'">yo<\/div>';
	document.getElementById('spiral'+y).style.top = (Math.sin(i)*100);
	document.getElementById('spiral'+y).style.left = (Math.cos(i)*100);
	divs[y] = i;
	i += 1;
	setTimeout('spiral()',500)
}

window.onload = function () { spiral(); }
</script>
What am I doing wrong?
__________________
Web Development
RegisterRants is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:51 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger