The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Operations with variables.

View previous topic View next topic Go down

Operations with variables.

Post by dudi on December 21st 2010, 8:05 pm

Is there a way to make operations with integer variables such as number of posts or number of members?

I would like to make announcement like this:

only {100-"current_number_of_members"} members left to our 100 members goal.

which should look like:

only 23 members left to our 100 members goal.

Hopefully u get the point.

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by MrMario on December 21st 2010, 8:11 pm


MrMario
Helper
Helper

Male Posts : 22186
Reputation : 1830
Language : test

http://test.com

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 8:15 pm

damn, u didn't get the point Very Happy

I ll be straight this time. Is there a way to add one variable to other, so when u type [FORUMCOUNTOPIC]+[FORUMCOUNTPOST] u get the number which is result of the previous operation?

I added [] on purpose so u can see what i want.

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by MrMario on December 21st 2010, 8:24 pm

Those are the only ones we have so there isn't any way of adding or changing.

MrMario
Helper
Helper

Male Posts : 22186
Reputation : 1830
Language : test

http://test.com

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 8:33 pm

Try this script:
Code:
<script>var members_countdown = 100-{FORUMCOUNTUSER}</script>
Put in the forum description.

How to write:
Code:
<script>document.write('only '+members+' members left to our 100 members goal.');</script>
Put in any place that accept scripts. (like in forum welcome message)


Sorry for my bad English (if you find errors on this post)!

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 8:57 pm

ok i get the point. with the first code you announce the variable and set it to that value.

but shouldn't 2nd code look like this:

Code:
<script>document.write('only 'members_countdown' members left to our 100 members goal.');</script>

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 9:05 pm

I've modified the var in 1st code and forgot the 2nd code!

correct 2nd code:
Code:
<script>if(members_countdow == 1){var members = "member";}else{var members = "members";};
document.write('only 'members_countdown' '+members+' left to our 100 members goal.');</script>


Last edited by Brasileiro Foda on December 21st 2010, 9:29 pm; edited 2 times in total

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 9:12 pm

So, what to do now?

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 9:14 pm

use this code:
my last post

the code:
Code:
<script>if(members_countdow == 1){var members = "member";}else{var members = "members";};
document.write('only 'members_countdown' '+members+' left to our 100 members goal.');</script>


Last edited by Brasileiro Foda on December 21st 2010, 9:31 pm; edited 1 time in total

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 9:31 pm

Ok, here is what i have done:

code 1 implemented here



code 2 implemented here



and it doesn't work for me. Although your script looks pretty logical, something is wrong.

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 9:35 pm

I've forgot the "else" (I'm not good with javascript), but now will work:
Code:
<script>if(members_countdown == 1){var members = "member";}else{var members = "members";};
document.write('only '+members_countdown+' '+members+' left to our 100 members goal.');</script>

see the code! (you will see the ELSE)

CODE MODIFIED! (again!)


Last edited by Brasileiro Foda on December 21st 2010, 9:55 pm; edited 2 times in total

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 9:47 pm

Still doesn't work. Even though u forgot to add < at the beginning. Please check is the place where i announced members_countdown variable fine? myb i should announce it somewhere else? or should i announce the string variable members also?

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 9:54 pm

My computer is slow and forget "<" at the beginning of the code

CODE MODIFIED! (again!)(and try again if don't work!)

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 10:05 pm

hmm, still doesn't work.. :/

Myb there is different code for output? And are you sure about sintax? I googled java output streams and sintax goes like this:

Code:
System.out.print("String argument");


dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 10:25 pm

I will try...

Works for me!

Description:
Code:
<script>var members_countdown = 100-{FORUMCOUNTUSER};</script>

Writer(what will write):
Code:
<script>if(members_countdown == 1){var members = 'member';}else{var members = 'members';};
document.write('only '+members_countdown+' '+members+' left to our 100 members goal.');</script>

See: http://www.piratenet.co.cc/portal

CODE MODIFIED! (Do not work in some places!)


Last edited by Brasileiro Foda on December 23rd 2010, 5:31 pm; edited 4 times in total

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

Re: Operations with variables.

Post by dudi on December 21st 2010, 10:33 pm

Nice, so here is the finale.

If i put first code in the site's description and second in the general message of the forum or category's description, it works fine.

In the other case, when i put it in the announcements, my forum colapses. So obviously, announcements don't support scripts.

Anyway, problem is solved, ty brasilerio foda for your time. Smile

dudi
Forumember

Male Posts : 104
Reputation : 30
Language : English

Back to top Go down

Re: Operations with variables.

Post by Brasileiro Foda on December 21st 2010, 10:37 pm

CODE MODIFIED!

Brasileiro Foda
New Member

Male Posts : 8
Reputation : 10
Language : Brazilian Portuguese and (bad!) English

http://www.piratenet.co.cc/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum