Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update the value of a text field

Status
Not open for further replies.

nalbiso

Programmer
Aug 31, 2000
71
US
Hi,

Can anyone provide me with a script on how to update the value of one text field based on the value of another text field? I would like to update the value of a text field on my form called "FutureHoursNeeded" based on the value inputted in another text field on my form called "PercentCompleted".

It should perform an operation to check
if (document.editProj.PercentCompleted.value=="100") {

and if it does then a value of 0 should be written to FutureHoursNeeded.

Any help is greatly appreciated! :)
 
What if the project is only half-finished?

Code:
<form name=projectReport>

<input type=text name=&quot;PercentCompleted&quot; onChange=&quot;calculateHoursNeeded()&quot; value=&quot;0&quot;> 
<input type=text name=&quot;FutureHoursNeeded&quot;> 

</form>



<script>
function calculateHoursNeeded(){
   var pDone = document.projectReport.PercentCompleted.value;
   var hoursTotal = 40;  //This could be picked up from a text field in the same form.
   
   hoursNeeded = hoursTotal * (1-(pDone/100));
   
   document.projectReport.FutureHoursNeeded.value = hoursNeeded;
}
</script>
 
Hi,

Thanks, but I only need this script to change future hours to 0 if percent completed is equal to 100. Future hours is only the visitor's estimate on how much time he/she will need on a project as different visitors can work more or less than 40 hours per week on a project and therefore are not consistent.

Another field on my form already computes the total hours expended on the project.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top