i have write a javascript code in dreamweaver mx 2004 :
here is the screenshoot of my page :
[IMG]http://i576.photobucket.com/albums/ss210/aripurwahyudi/albumin-correction-formula-view.jpg[/IMG]
Summary for the picture is :
input in : Body weight, actual albumin, target albumin, is a number : decimal and or absolute number

i need this tabel work if i fill in input of body weight, actual albumin, and target so automactictly in field of albumin correction shon the result.

Original Formula = Amount of Correction = (D-A)X((BWX40)/100)X2 = ....grams

For the form and component includes i have write the javascripts here, but when execute on web page that is not work !!

SOMEBODY CAN HELP ME FIND MY ERROR CODE ?? Many thanks for helping

Here the code :

<script language="JavaScript">
  function calcul(albumincorrection){ 
   var wt = Number (albumincorrection.wt.value);
   var actual = Number (albumincorrection.actual.value);
   var target = Number (albumincorrection.target.value);
   var correction = Number (albumincorrection.correction.value); 
 
   correction = (target - actual)* ((wt*40)/100)*2  
}
</script>

and here the complete code for my page :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Albumin Correction Formula</title>
<script language="JavaScript">
  function calcul(albumincorrection){ 
   var wt = Number (albumincorrection.wt.value);
   var actual = Number (albumincorrection.actual.value);
   var target = Number (albumincorrection.target.value);
   var correction = Number (albumincorrection.correction.value); 
 
   correction = (target - actual)* ((wt*40)/100)*2  
}
</script>

<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
	color: #0000CC;
}
.style3 {font-size: 18; font-weight: bold; color: #990000; }
.style5 {color: #006600}
.style6 {
	color: #006600;
	font-weight: bold;
}
.style7 {
	color: #009900;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<form name="albumincorrection" id="albumincorrection" method="post" action="">
  <table width="370" border="1">
    <caption align="top">
    <span class="style1"> Albumin Correction Formula  </span>
    </caption>
    <tr>
      <th width="198" scope="col"><div align="left" class="style3">Body Weight </div></th>
      <th width="156" scope="col">
        <div align="left">
          <input name="wt" type="text" id="wt" size="5" /> 
          <span class="style5">kg
        </span> </div></th>
    </tr>
    <tr>
      <td><span class="style3">Actual Albumin </span></td>
      <td>
        <div align="left">
          <input name="actual" type="text" id="actual" size="5" input=/>
          <span class="style6">mmol/ dL </span></div></td>
    </tr>
    <tr>
      <td><span class="style3">Target Albumin </span></td>
      <td><input name="target" type="text" id="target" size="5" /> 
        <span class="style5"><strong>mmol/ dL </strong></span></td>
    </tr>
    <tr>
      <td><span class="style3">Albumin Correction</span></td>
      <td><div align="left">
        <input name="correction" type="Number" id="correction" size="5" maxlength="5" input= /> 
        <span class="style5"><strong>gram
        </strong></span></div></td>
    </tr>
    
  </table>
      <p>&nbsp;</p>
</form>
</body>
</html>

There is such a type of 'number' for input tag. Not sure where you got the idea from??? Anyway, a suggesting revised code is below. The function takes the form ID and obtain input values from the form's input elements. The 'correction' is 'readonly' so user wouldn't accidentally change it. This form use 'button' to call the function. You could use onchange() event, but that may be confusing for you right now. Hope this help.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Albumin Correction Formula</title>
<script language="JavaScript">
 function calcul(formID) {
   var formObj = document.getElementById(formID)
   if (formObj) {
     var wt = parseFloat(formObj.wt.value, 10);
     var actual = parseFloat(formObj.actual.value, 10);
     var target = parseFloat(formObj.target.value, 10);
     formObj.correction.value = (target - actual)*((wt*40)/100)*2;
   }
 }
</script>

<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
	color: #0000CC;
}
.style3 {font-size: 18; font-weight: bold; color: #990000; }
.style5 {color: #006600}
.style6 {
	color: #006600;
	font-weight: bold;
}
.style7 {
	color: #009900;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<form name="albumincorrection" id="albumincorrection" method="post" action="">
  <table width="370" border="1">
    <caption align="top">
    <span class="style1"> Albumin Correction Formula  </span>
    </caption>
    <tr>
      <th width="198" scope="col"><div align="left" class="style3">Body Weight </div></th>
      <th width="156" scope="col">
        <div align="left">
          <input name="wt" type="text" id="wt" size="5" />
          <span class="style5">kg
        </span> </div></th>
    </tr>
    <tr>
      <td><span class="style3">Actual Albumin </span></td>
      <td>
        <div align="left">
          <input name="actual" type="text" id="actual" size="5"/>
          <span class="style6">mmol/ dL </span></div></td>
    </tr>
    <tr>
      <td><span class="style3">Target Albumin </span></td>
      <td><input name="target" type="text" id="target" size="5" />
        <span class="style5"><strong>mmol/ dL </strong></span></td>
    </tr>
    <tr>
      <td><span class="style3">Albumin Correction</span></td>
      <td><div align="left">
        <input name="correction" type="text" id="correction" size="5" maxlength="5" readonly />
        <span class="style5"><strong>gram
        </strong></span></div></td>
    </tr>

  </table>
      <p>&nbsp;</p>
      <input type="button" value="compute" onclick="calcul('albumincorrection')">
</form>
</body>
</html>

yes, just my very thanks saying to you
i have recoded my page and its work !!!!
very thanks abaout its and the explaining me about my error
hopefull i still much much leran more
very nice and thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.