You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 62 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Problem with Custom Block Java Coding "Clean Time Calcu [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
chadrt
Nuke Soldier
Nuke Soldier


Joined: Oct 03, 2005
Posts: 21


PostPosted: Wed Feb 07, 2007 4:05 pm Reply with quoteBack to top

I have modified this block and reworked it but I am having no luck, getting it to function any help would be wonderful. Below are the two code snippets Block is disfunctional and the html version works perfectly. Thanks any assistance anyone is willing to give me on this one. Smile

Working HTML Version: www.myrecoveryna.org/html.txt

Non Working Block: www.myrecoveryna.org/block.txt

I have tracked down several errors in the form section and finally got the thing to quit making the pages go blank. Now if I can just get it to calculate I would happy. The script is designed to calculate the amount of clean time that a recovering drug addict has been away from drugs. Thanks again for your help. I had to use txt files because it wont let me use any html even in the code brackets.

Chad
www.myrecoveryna.org
Find all posts by chadrtView user's profileSend private message
arnoldkrg
Major
Major


Joined: Aug 03, 2003
Posts: 937

Location: United Kingdom

PostPosted: Thu Feb 08, 2007 4:30 pm Reply with quoteBack to top

In includes/javascript.php add the following right underneath the closing ?> tag
Code:
<S CRIPT LANGUAGE="JAVASCRIPT">
accuracy = 3;

function roundAtDecimalPosition(number,accuracy) {
    return Math.round(number * Math.pow(10,accuracy)) / Math.pow(10,accuracy); }

function roundAtDecimalPosition(n,position) {
    n = n * Math.pow(10,position);
    n = Math.round(n);
    n = n / Math.pow(10,position);
    return n; }

function lifetimer(){           
        today = new Date()
        BirthDay = new Date(document.live.age.value)
        timeold = (today.getTime() - BirthDay.getTime());
        sectimeold = timeold / 1000;
        secondsold = Math.floor(sectimeold);
        msPerDay = 24 * 60 * 60 * 1000 ;
        timeold = (today.getTime() - BirthDay.getTime());
        e_daysold = timeold / msPerDay;
        daysold = Math.floor(e_daysold);
        e_hrsold = (e_daysold - daysold)*24;
        hrsold = Math.floor(e_hrsold);
        minsold = Math.floor((e_hrsold - hrsold)*60);
        document.live.time1.value = daysold   
        document.live.time2.value = hrsold
        document.live.time3.value = minsold
        document.live.time4.value = roundAtDecimalPosition(daysold/365,accuracy)
        window.status = "Well at the moment you are " + secondsold + "............ seconds old.";         
        timerID = setTimeout("lifetimer()",1000) }       

// -- done hiding from old browsers -->

</s cript>


That is after all existing code. (I have added a space into the opening and closing script tags to allow it to display here so remove that.) This places your javascript between the head tags of your site, just as you have it on your html page.

Code:
<?php
if (eregi("block-lifetimer.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
}

$content = "";

$stuff = <<< End_Stuff

<form name="live" method="post">
Your Clean Date Please:<br>
<INPUT TYPE="text" NAME="age" VALUE="" SIZE=20><br>
Example: (November 1, 1966)<br>
<INPUT TYPE="button" NAME="start" VALUE="Calculate" ONCLICK="lifetimer(this.form)">
<INPUT TYPE="reset" NAME="resetb" VALUE="Clear">
<p> <br>
You've been clean:
<INPUT TYPE="text" NAME="time4" VALUE="" size=8>years<br>
You are <INPUT TYPE="text" NAME="time1" VALUE="" size=5>

 days,&nbsp; <INPUT TYPE="text" NAME="time2" VALUE="" size=3>

 hours and <INPUT TYPE="text" NAME="time3" VALUE="" size=3>minutes
clean.</p>
</form>

End_Stuff;

$content .= $stuff;

?>


Save the above as block-lifetimer.php and upload to the blocks directory of your server. WARNING..... the copy/paste process sometimes adds invisible blank characters to the ends of code lines. These must be removed using a decent text editor before uploading to your site I use Crimson Editor

Next go to admin.php ..... Blocks and create your block by scrolling down and giving it a title. Next select lifetimer from the dropdown Filename select box and click create.

Tested and working on a Nuke 8.0 site.

_________________
Image
Find all posts by arnoldkrgView user's profileSend private messageSend e-mailVisit poster's website
chadrt
Nuke Soldier
Nuke Soldier


Joined: Oct 03, 2005
Posts: 21


PostPosted: Sat Feb 10, 2007 3:30 pm Reply with quoteBack to top

Thank you so much, I have fought with that thing for a couple of days now. I really appreciate you!! This site is not quite off the ground yet but I am hoping that it will become popular and things like that are just really nice for others to tell their friends about. Thanks again.

Sincerely,
Chad Taylor
Find all posts by chadrtView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.818 Seconds - 537 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::