Click to See Complete Forum and Search --> : Using a Javascript function in an <INPUT>


jshowe
07-01-2003, 09:33 AM
Hi,

I am trying to do call to a function "reCalc()" that returns a value.

<INPUT value='recalc()' name=Total>";

it just gives me "reclac()" in an input box instead of resolving it first.

Any ideas? Thanks!

khaki
07-01-2003, 09:44 AM
hi jshowe...

why not just have the function populate the field...
something like this :

<script type="text/javascript">
function recalc()
{
now = new Date();
document.form1.Total.value= now
}
</script>
</head>
<body onload="recalc()">
<form name="form1" method="post" action="">
<input type="text" name="Total">
</form>
</body>

will that work for you?

;) k

EDIT:
ooops.
Dave already beat me to the punch :rolleyes:
(really gotta be quick around here, I guess :) )

jshowe
07-01-2003, 10:03 AM
Thank you both for your help.

Khaki - I ended up doing exactly what you suggested and that works great!

khaki
07-01-2003, 10:24 AM
YIKES!!!!

Dave is even beating me to my own acknowledgments!!! :)
I think that I'll just kick-back and let Dave handle the rest of my responses today :)

ahhhh....
life is easy :)

;) k

khaki
07-01-2003, 11:09 AM
oh please...

I'm just playing
(you should know that)

I guess we haven't shared many threads lately, and you've misplaced the English-to-khaki cross-reference manual.

So NO...
I don't want you to remove any reference to yourself :rolleyes:
(although feel free to correct my horrible grammer and punctuation :) LOL)

;) k

PS to jshowe :
you're welcome :)

jshowe
07-01-2003, 05:37 PM
Hey Dave,

I started thinking about what you had wrote and gave it another try. When I load the page I get this message:

Java script Error

Description:'document.TheForm.Total' is null or is not an object

Any ideas why?

BTW - I changed it a little to suit my needs better:

<script type="text/javascript">
document.TheForm.Total.value = 70.00;
</script>

I figured a constant would be better for troubleshooting and yes I did want it to do it on page load.