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

  • Thread starter Charles M. Fish, Sr.
  • Start date
C

Charles M. Fish, Sr.

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
==
 
I

Ivo

Charles M. Fish said:
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
 
C

Charles M. Fish, Sr.

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
==
 
C

Charles M. Fish, Sr.

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
==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top