INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Execute JavaScript when page loads

Execute JavaScript when page loads

(OP)
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

CODE --> 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!!!!

RE: Execute JavaScript when page loads

CODE --> 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.

RE: Execute JavaScript when page loads

(OP)
ChrisHirst,

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

RE: Execute JavaScript when page loads

Quote:

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close