siby Posted August 5, 2016 Share Posted August 5, 2016 Hi Jacques1, I have written this code for a biorhythm calculator but I can't figure out why it doesn't work, would you be able to take a look and see if you can find the problem? It would be greatly appreciated, thank you. <html> <head> <script> var months = 'janfebmaraprmayjunjulaugsepoctnovdec'; var PI = 3.14159265358979323846; var msPerDay = 1000*60*60*24; var interllectualCycle = 33; var emotionalCycle = 28; var physicalCycle = 23; var birthYear = parseInt(prompt( 'Enter year of birth as a 4 digit integer' )); var birthMonth = prompt( 'Enter name of month of birth' ); //request month of birth var pos = months.indexOf(birthMonth.substring(0, 3) .toLowerCase() ); var posMonth = pos / 3; //alert( 'Month number: ' + pos ); //convert month to number var numberInString = posMonth; var numberMonth = new Number(numberInString); // alert(numberMonth); var birthDay = parseInt (prompt('Enter day of birth as an integer')); //enters birthdate into string var userBirthday = new Date(birthYear, numberMonth, birthDay); //alert ('' + userBirthday); //date object created for current date var currentDate = new Date(); // alert ('' +currentDate) //creating users age in milliseconds var msSinceBirth = currentDate.getTime()- userBirthday.getTime() ; // alert ('' +msSinceBirth); //creating users age in days var userMsDays = Math.floor(msSinceBirth / msPerDay); //document.write ('' + userMsDays); var bioEnergy = (userMsDays * (2 * PI ) / interllectualCycle); var bioEmot = (userMsDays * (2 * PI) / emotionalCycle); var bioPhy = (userMsDays * (2 * PI) / physicalCycle); //Biorhythm energy levels output document.write('You have been alive' + userMsDays + 'days'); document.write('<h1>"Your biorhythm energy levels are :-"</h1>'); document.write('<ul>'); document.write('<li><font color="green">intellectual:</font></li>' + [Math.sin(bioEnergy).toFixed(1)]); document.write('<li><font color="red">emotional:</font></li>' + '' + [Math.sin(bioEmot).toFixed(1)]); document.write('<li><font color="blue">physical:</font></li>' + [Math.sin(bioPhy).toFixed(1)]); document.write('</ul>'); </script> </head> </html> Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/ Share on other sites More sharing options...
Jacques1 Posted August 5, 2016 Share Posted August 5, 2016 Don't hijack threads of other users, create your own. And the chance of somebody helping you with “the problem” is close to zero if you won't even tell what “the problem” is. Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535643 Share on other sites More sharing options...
siby Posted August 5, 2016 Author Share Posted August 5, 2016 I'm sorry, I'm new to this website and I didn't know you couldn't post on others threads. I don't know what the problem is, which is why I can't explain it. I was under the impression you knew a great deal about coding and could help me out by identifying the problem, as I am new to coding and am having trouble. Thanks for your time though. Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535644 Share on other sites More sharing options...
Jacques1 Posted August 5, 2016 Share Posted August 5, 2016 What kind of trouble? Does your PC catch fire when you run the script? Do you get an error message? A specific unexpected result for a specific input? I know this is hard to understand, but we're not sitting in front of your screen, and we cannot read your mind. All you've provided is a wall of code and the vague information that you think there's something wrong with it. What are we supposed to do now? Be specific. Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535645 Share on other sites More sharing options...
requinix Posted August 5, 2016 Share Posted August 5, 2016 Thread split Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535646 Share on other sites More sharing options...
siby Posted August 5, 2016 Author Share Posted August 5, 2016 Well when I try opening it in a web browser, it doesn't display the pop up's with text boxes which I thought I had gotten it to do. See when you open it in firefox or chrome it's supposed to ask for your year of birth then month then date, but it just opens a page with the code. Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535647 Share on other sites More sharing options...
Jacques1 Posted August 5, 2016 Share Posted August 5, 2016 Are you sure the filename has an .htm or .html extension? Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535648 Share on other sites More sharing options...
siby Posted August 5, 2016 Author Share Posted August 5, 2016 Oh wow, thank you so much, I can't believe it was that simple! It doesn't give me the correct answer when I type the information in, but I'll try and figure that out. thank you thank you thank you! Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535650 Share on other sites More sharing options...
Jacques1 Posted August 5, 2016 Share Posted August 5, 2016 The code you claim to have “written” is copied and pasted from another user without any attribution. If this is homework, you're now screwed. Quote Link to comment https://forums.phpfreaks.com/topic/301767-this-calculator-thing-doesnt-work-help-me-jacques-youre-my-only-hope/#findComment-1535654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.