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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute JavaScript when page loads 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
0
0
US
Hello,

I have a JavaScript program that gets data from a table, I am trying to add two fields and then write to a third field.

Scenario,
first field "timein" static field this field has data
second field "timeout" dynamic field the time will be written when the save button is pressed
third field "tottime" this field is ("timeout" - "timein")/100
all this works well, the problem that I have is that I want to make all my fields read only so the user cannot change the time

the script that I have has
JavaScript:
var ctrltimein = Runner.getControl(pageid, 'TIMOUT');

var ctrltimeout = Runner.getControl(pageid, 'TIMEIN');

var ctrlTotal = Runner.getControl(pageid, 'TOTTIM');

  

function func() {

  ctrlTotal.setValue(Number((ctrltimeout.getValue()) - Number(ctrltimein.getValue()))/100); 

}; 

  
ctrlTotal.on('keyup', func);

This code works well but only if the I make the "totem" not read only so the user can click on it and then it will calculate.

I need it to calculate when the page loads, I have tired 'load', 'mouseover', etc and none of these work.
Any help is much appreciated.

thanks!!!!
 
JavaScript:
<script type="javascript/text">window.onload = function_name(parameters);<script>


at the bottom of the document body.

OR

use the body onLoad event attribute

OR

Choose an alternative from these.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
ChrisHirst,

thank you, I tried all of them but none seem to work. I really appreciate the guidance.

 
that I want to make all my fields read only so the user cannot change the time

Store the 'real' value in a hidden input element.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top