HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media


Welcome to TinyPortal. Please login or sign up.

September 22, 2023, 08:16:12 PM

Login with username, password and session length
  • Total Posts: 194,538
  • Total Topics: 21,180
  • Online today: 112
  • Online ever: 3,540
  • (September 03, 2022, 01:38:54 AM)
Users Online
Users: 1
Guests: 92
Total: 93

Help making Javascript function work correctly Die roller block

Started by pjr, March 15, 2006, 02:23:50 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.


Below is a bit of simple code that doesnt work. How do I get the button push to make the call and return the value? Also for some reason there is a lot of blank space above the table when I create it. Can one of you more experianced TP useres help me out here?

<!-- Begin
var die = 6;
var dice = 3;
function dice_roll(die, dice) {
var roll = 0;
for (loop=0; loop < dice; loop++) {
roll = roll + Math.round(Math.random() * die) % die + 1;
document.roller.drtext.value = roll;
// End -->

<form name=roller>
<table border=2 cellpadding=2>
<td colspan=1 align=middle>Type?</td>
<td colspan=1 align=middle>Number?</td>
<td valign=top align=middle>
<p><input type=radio name=sides onclick="die = 2">2
<p><input type=radio name=sides onclick="die = 4">4
<p><input type=radio checked name=sides onclick="die = 6">6
<p><input type=radio name=sides onclick="die = 8">8
<p><input type=radio name=sides onclick="die = 10">10
<p><input type=radio name=sides onclick="die = 12">12
<p><input type=radio name=sides onclick="die = 20">20
<p><input type=radio name=sides onclick="die = 100">100
<td valign=top align=middle>
<p><input type=radio name=number onclick="dice = 1">1
<p><input type=radio name=number onclick="dice = 2">2
<p><input type=radio checked name=number onclick="dice = 3">3
<p><input type=radio name=number onclick="dice = 4">4
<p><input type=radio name=number onclick="dice = 5">5
<p><input type=radio name=number onclick="dice = 6">6
<p><input type=radio name=number onclick="dice = 8">8
<p><input type=radio name=number onclick="dice = 10">10
<td align=middle colspan=2>
<input type=button value="Roll Dice" name=button onclick="dice_roll(die, dice)">
<input type=text size=10 name=drtext>


Works fine for me. See the screenshot below. What I think you've done, is not change the block type from html to javascript/html. This will leave a space at the top.

[attachment deleted by admin]


You're correct I actually discovered that shortly after I posted. I thought I had deleted this post too. oh well! :)

Thanks however!



It works fine for me too.

Thanks for the code by the way. I made some small changes but it will fit in well with my RP site.


well I am running a play by post rpg site here so yes and no crip. Mitch what changes did you make always like to tinker myself...:)


Is that (Fire-Fly) a TV series on Si-Fi channel?
......If it is, I love that show, I've not missed one episode yet..
...I'm also a huge SG-1 fan too.. :)


Yes it is. It originally aired on Fox they canceled it and there was a movie called Serenity all available on DVD now


Quote from: pjr on March 15, 2006, 03:38:38 PM
well I am running a play by post rpg site here so yes and no crip. Mitch what changes did you make always like to tinker myself...:)

you can check it out here but be nice I am in midst of changing the site soo its a mess.
Not alot of things I just changed the looks of it a bit.

I heard I should watch fire fly

and serenity was a damn good movie.


on TV, is Serenity the ship.. or the beautiful companion?  :P :P :P
I know who Jewel Satie is, not her but the capanion is Serenity??


Inara is the companion. The ship is Serenity.

And for the record my favorite woman was Saffron from the Our Mrs Reynolds episode

All your questions can be answered here...


anyone know how to add color to this roller
my back ground is black so it wont let me see the numbers


odd so is mine and I get white text......
put the tags <color=white> </color> arround it should work


then i have done something wrong :)

1st i took a block made it html/java. then i edited it and added the script