3.2.0

Html help.

I want to modify this code to add 1-4 stars to a particular forums topic title when a user rates the topic. e.g user chooses option1 'excellent' then 5 stars appear next to the topic title. Help?

[quote]<BODY>

<CENTER>
<FORM>
<TABLE BORDER=2 WIDTH=500>
<TR>
<TD align="center"><FONT SIZE=+1><B>Rate</B></FONT>
<TD align="center"><FONT SIZE=+1><B>Question</B></FONT>
</TR>
<TR>
<TD align="center"><SELECT NAME="menu" SIZE=1>
<OPTION SELECTED VALUE=""> --- Rate this thread ---
<OPTION VALUE="one">Excellent
<OPTION VALUE="two">Informative
<OPTION VALUE="three">Not bad
<OPTION VALUE="four">Nice pics
<OPTION VALUE="five">Pointless Drivel
</TR>
</TABLE>
<BR>
<TABLE BORDER=0 WIDTH=400>
</TABLE>
<BR>
</FORM>
</CENTER>
<!-- Script Size: 3.04 KB -->

[/quote]
January 16,
can somebody help with this, please?
January 16,
Will this rating be just for that session, or should it be visible to all users?? (i.e. it should be stored somewhere)

I would say add a button which reloads the page...

<INPUT type=button value=VOTE onClick=rate()>

<SCRIPT type=JavaScript>
function rate()
{
if document.forms.menu.value!=="one"
{
this.location=URL
document.write=('*****') [inserted at the right place...]
}
else if



etc. I'm not a javascript wizard, but if you make a textbox or similar to enter the stars after each topic, you can fill it with the correct number of stars (default=0) depending on the vote
Tinus de Vries
January 16,
Well, for starters you are going to need some server side scripts to do calculations. Just changing the image, will not span accross new users when you visit the post you are trying to rate. Your server side script needs to take the values you pass from the list "excellent" and at to the score talley. Then you have to calculate based on the number of ratings and votes.

(TOTALRATINGS / (TOTALVOTES*5)) * 100 will get you the percentage
Tony
January 16,
I want the set amount of stars to appear next to the topic title.
that number of stars should appear there only until the next person re-rates it. If the next person rates it 3 stars then the three stars remain next to the topic title until its rated again. perhaps this would need a 'reset' button and a 'vote' button to allow it to go from say, 5 stars, back to 3?

preferably it should be a simple as possible and javascript. Also a rating should be 're-settable for each topic. so that one topic might show 5 stars, another only 3. but rating for one topic should not affect the rating for another.

im using ipb 1.3 board. the script would go in ~topic veiw > Footer
if thats any help. Much, much obliged if someone can come up with a script for this, im hopeless at coding beyond extreme basics, and have searched the web endlessly for such a script without success.

Thankyou very much, in advance, and Thankyou very much those who have replied already :)
Dan
January 16,
Forgot to add, Yes stars next to topic titles should be visible to all users.
Dan
January 16,
Can anyone do this with javascript? Is it even possible?
January 17,
Trick is to store the info. Easiest wat would be to write it away to a text-file. This can't be done with JavaScript. PHP should do the trick, but I don't speak PHP unfortunately...
Tinus de Vries
January 17,
Me either, hence looking for javascript. even the simplest script would be great. Im not a coder/programmer.
January 17,
<script type=text/JavaScript>
function voting(n)
{
var rating=new Array()
rating[0]=""
rating[1]="*"
rating[2]="**"
rating[3]="***"
rating[4]="****"
rating[5]="*****"
var result=rating[n]
}

in which the function voting is activated by the vote button and the n is determined by the selected option.

In the body of the thread list:
Thread1 name: <FORM name=thread1><INPUT name=star size=5></FORM><BR>

In the input box you put the correct number of stars...

<SCRIPT type=text/JavaScript>
document.forms.thread1.star.value=""+result+""
</script>


It's not your solution, only the start of it...
Prob is that this script won't show the rating to other viewers.
Tinus de Vries
January 17,
here's a good place to start looking: http://www.php-freelancers.com/
Dmitry
January 17,
Thankyou so much :)
January 18,
var rating=new Array()
rating["Terrible"]=""
rating["Poor"]="*"
rating["Soso"]="**"
rating["average"]="***"
rating["Good"]="****"
rating["Excellent"]="*****"

but you need server side code as Tony pointed out on Monday.
sl
January 18,
What is server side code?
January 18,
Unfortunately, if you don't know. You got a ways to go before you will get anything working. Server side code is scripting languages such as PHP, Perl, Python, ASP... the list goes on. I suggest purchasing a book on one of those flavors, and/or doing some online research. You may want to search for "Hello World! PHP" for starters.
Tony
January 18,

This topic is archived.

See also:


Back to support forum