Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Why doesn't this work? Noob question.
Old 05-09-2010, 02:13 PM Why doesn't this work? Noob question.
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Code:
<script type="text/javascript">
function fader() {
  var Opacity = document.getElementById('fadeBox').style.opacity;
  Opacity + 0.2;
}
setInterval("fader()", 1500);
</script>
<div style="background:blue;color:white;padding:10px;width:300px;opacity:0.1;" id="fadeBox">Hi there...</div>



.
It's supposed to increase the opacity of fadeBox every 1.5 seconds... But it doesn't
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-09-2010, 03:37 PM Re: Why doesn't this work? Noob question.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Your script never writes the new value back to the element, it simply reads the existing value from the element each time.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-09-2010, 03:40 PM Re: Why doesn't this work? Noob question.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Oh and of course it will need a check so the final value does not go over the maximum value.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-09-2010, 05:37 PM Re: Why doesn't this work? Noob question.
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
So ummmm how would I fix it? I am a noob at js
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 05-09-2010, 06:56 PM Re: Why doesn't this work? Noob question.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
One of my "playing pages"

http://www.modtalk.co.uk/_site/code/css/opacity/

I keep meaning to add the crossbrowser bits (well the Internet Exploder bits)
HTML Code:
	var fadeInId = 0;
	var fadeOutId = 0;
	var opac = 0;
	var e = null;
	
function fadeIn() {
	if(opac < 1) {
  		opac = opac + 0.01;
	} else {
		clearInterval(fadeInId);
		fadeOutId = setInterval("fadeOut()", 100);
		e.innerHTML = "Fade Out";
	}

	e.style.opacity = opac;
}
function fadeOut() {

	if(opac > 0) {
  		opac = opac - 0.01;
	} else {
		clearInterval(fadeOutId);
		fadeInId = setInterval("fadeIn()", 100);
		e.innerHTML = "Fade In";
	}
	e.style.opacity = opac;
}

function fadeInit(eID) {
	e = document.getElementById(eID);
	fadeInId = setInterval("fadeIn()", 100);
}
jquery? mootools? PPPPFFTTTT!!!!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Why doesn't this work? Noob question.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30731 seconds with 12 queries