User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,186 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

debugging?

Join Date: Jul 2005
Posts: 37
Reputation: jasondrey13 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
jasondrey13 jasondrey13 is offline Offline
Light Poster

Troubleshooting debugging?

  #1  
Mar 8th, 2008
hey im really new with javascript.
can someone tell me whats wrong with this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <title>calculate distance and slope between two points</title>
  
  <script language="javascript">
  <!--
  
  var x1=0;
  var y1=0;
  var x2=0;
  var y2=0;
  var xdif=0;
  var ydif=0;
  var xsldif=0;
  var xdifsquared=0;
  var ydifsquared=0;  
  var undersquare=0;
  var distance=0;
  var slope=0;
  
  function calculate()
   {
  
  x1=document.calcform.inpx1.value;
  y1=document.calcform.inpy1.value;
  x2=document.calcform.inpx2.value;
  y2=document.calcform.inpy2.value;
  
  xdif=x2-x1;
  ydif=y2-y1;
  
  xdifsquared=xdif*xdif;
  ydifsquared=ydif*ydif;
  
  undersquare=xdifsquared+ydifsquared;
  
  distance=Math.sqrt(undersquare);
  slope=ydif/xdif;
  
  //-->
  }  
  

  </script>
  </head>
  <body>
  
  <p><img src="distanceformula.gif" border="1">  </p>
  <p><img src="slope.gif" border="1"></p>
  <form name="calcform">
  <p>point 1: ( 
    <input type="text" name="inpx1" size="5"> 
    , 
    <input type="text" name="inpy1" size="5"> 
    ) <br>
 point 2: ( 
 <input type="text" name="inpx2" size="5"> 
 , 
 <input type="text" name="inpy2" size="5"> 
 )<br>
  </p>
  <button type="submit" onClick="calculate();">Calculate!</button>
  <p>
    <strong>distance:</strong>
    
  <script language="javascript">document.write(distance);</script>
  
  </p>
  <p><strong>slope:</strong><br>
    <script language="javascript">document.write(slopetop);</script>
    
<br>
-----    = <script language="javascript">document.write(slopefinal);</script><br>

    <script language="javascript">document.write(slopebottom);</script>
    <br>
  </p>
  </form>




  </body>
</html>


thanks so much,
Jason
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 10:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC