HighDots Forums  

Trying to execute a function *following* RESET clearing the textfields...

Javascript JavaScript language (comp.lang.javascript)


Discuss Trying to execute a function *following* RESET clearing the textfields... in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Charles M. Fish, Sr.
 
Posts: n/a

Default Trying to execute a function *following* RESET clearing the textfields... - 09-22-2003 , 08:38 PM






I’m so tired from banging this problem around all day, I hope I can
explain it succinctly & accurately.

I want to execute a function immediately following a click on <input
type="RESET"...

The function will insert today’s date into a <input type="TEXT"… field.
It does it just fine with <form onload="insertDate();" where inside the
‘insertDate’ fn, I have document.form.dateField.value = dateString. The
closest I’ve been able to do anything to repopulate <input type=”TEXT”
name=”dateField”… is with the onMouseOut event handler associated with
the <input type=”RESET”… object. Aaarrghh!

Here’s kind of an example:

<script>
// global var
var dateString = ""

function insertDate()
{
// …code that assigns formatted string for today’s date
dateString = dayname[weekday]+" "+day+" "+monthname[month]+" "+year;
}
</script>
</head>
<body...
<form onLoad="insertDate();"...

<input type=”text” name=”dateField” readonly>
..
..
..
<input type="reset" name="reset" value="reset"...
on... I don’t know what (eventHandler) can execute a function call after
RESET is executed>


I’ve even tried a dummy (pseudo) reset where RESET is a mere ‘button’
and I can call any function I want thru the onClick handler; but then
I can’t restore radio buttons to their default (initialized at form
load) values.

Any assistance will be genuinely appreciated!

Maybe you have solutions for both problems (automatic restoration of
dateString following RESET *** AND *** reassigning programmatically the
radio values?!?

beaucoup thanx in advance,
Chuck
==


Reply With Quote
  #2  
Old   
Ivo
 
Posts: n/a

Default Re: Trying to execute a function *following* RESET clearing the text fields... - 09-22-2003 , 10:20 PM






"Charles M. Fish, Sr." <AmandaReckonwith (AT) notDot (DOT) com> wrote

Quote:
I’m so tired from banging this problem around all day, I hope I can
explain it succinctly & accurately.

I want to execute a function immediately following a click on <input
type="RESET"...

snip

<input type=reset onclick="document.f.txt.value='whatever';">
doesn't work, but
<input type=reset onclick="setTimeout('document.f.txt.value=\'Hi.\'; ',1);">
has no probs.
HTH
Ivo




Reply With Quote
  #3  
Old   
Charles M. Fish, Sr.
 
Posts: n/a

Default Re: Trying to execute a function *following* RESET clearing the textfields... - 09-24-2003 , 10:28 AM



Ivo, Hi... Thank you for your reply.

I'm still having difficulties with getting something (*anything*) to
occur upon execution of <input type="reset"...

I tried your suggested line (verbatim except for substituting order &
orderDate) and my Netscape | Tools | Web Development | Javascript
Console returns:

Error: unterminated string literal
Source Code:
setTimeout('document.order.orderDate.value=\'Hi.\' ;',1);">

I don't understand the pair of backslashes surrounding 'Hi. are they
supposed to swap a string literal for a variable?

Again, I want to restore a variable( not a literal) to a readonly text
field after executing a true "reset".

Is it possible?

TIA
C
==

Ivo wrote:

Quote:
"Charles M. Fish, Sr." <AmandaReckonwith (AT) notDot (DOT) com> wrote in message
news:3F6FA3D2.1060604 (AT) notDot (DOT) com...


I’m so tired from banging this problem around all day, I hope I can
explain it succinctly & accurately.

I want to execute a function immediately following a click on <input
type="RESET"...



snip

input type=reset onclick="document.f.txt.value='whatever';"
doesn't work, but
input type=reset onclick="setTimeout('document.f.txt.value=\'Hi.\'; ',1);"
has no probs.
HTH
Ivo






Reply With Quote
  #4  
Old   
Charles M. Fish, Sr.
 
Posts: n/a

Default Re: Trying to execute a function *following* RESET clearing the textfields... - 09-24-2003 , 01:53 PM



Whoops, please ignore my ignorance about the backslashes!

I realize that they're for escape-apostrophe.

Still, any way to plug in a variable, not literal, value in a <input
type="text"... ???

TIA,
C
==

Charles M. Fish, Sr. wrote:

Quote:
Ivo, Hi... Thank you for your reply.

I'm still having difficulties with getting something (*anything*) to
occur upon execution of <input type="reset"...

I tried your suggested line (verbatim except for substituting order &
orderDate) and my Netscape | Tools | Web Development | Javascript
Console returns:

Error: unterminated string literal
Source Code:
setTimeout('document.order.orderDate.value=\'Hi.\' ;',1);"

I don't understand the pair of backslashes surrounding 'Hi. are they
supposed to swap a string literal for a variable?

Again, I want to restore a variable( not a literal) to a readonly text
field after executing a true "reset".

Is it possible?

TIA
C
==

Ivo wrote:

"Charles M. Fish, Sr." <AmandaReckonwith (AT) notDot (DOT) com> wrote in message
news:3F6FA3D2.1060604 (AT) notDot (DOT) com...


I’m so tired from banging this problem around all day, I hope I can
explain it succinctly & accurately.

I want to execute a function immediately following a click on <input
type="RESET"...



snip

input type=reset onclick="document.f.txt.value='whatever';"
doesn't work, but
input type=reset
onclick="setTimeout('document.f.txt.value=\'Hi.\'; ',1);"
has no probs.
HTH
Ivo







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.