Javascript question

  • Thread starter Thread starter Shawn Repphan
  • Start date Start date
S

Shawn Repphan

I apoligize if this is out of scope with this group. I have a textbox that
displays a current record number(xx of xxx). The user has the ability to
enter their own number into this box and perform a postback to get the n'th
record. I have client-side script that checks to see if any fields have
changed so that the user doesn't accidently lose any updated info. If any
fields have changed a javascript confirm box pops up. The only issue with
this is if the user clicks cancel, the field displaying the record number
still has whatever the user entered. Pressing ESCAPE will revert back to the
old number. What is the standard way of performing this with javascript? I
know I could probably use a hidden textbox or a global variable, but is
there a cancel command or something similar?
 
You could reset your textbox to it's defaultValue:
myTextbox.value = myTextBox.defaultValue;
 
You haven't described the problem completely. You have described the user
interface elements, and the results of what happens when they are employed
in a certain manner. However, you have neglected to mention exactly what
they *do.*

*How* does the user "perform a postback?" What action triggers the postback?
*How* does the client-side script check to see if any fields have changed?
What action triggers this action (whatever it is)?
*What* happens when the user clicks Cancel?
*Why* does pressing ESCAPE "revert back the old number?"

Remember, you wrote this application. We know nothing about how it works. If
we are to help you debug it, you must tell us how it works.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 
I have solved my problem. I decided to go with the hidden textbox method.

It works as follows:

The currentrecord textbox fires the onChange event which first calls a js
function to determine if a hidden field contains the value of true. This
hidden field is set to true by the onChange event of all the other textboxes
on the form. If the value is true, the confirm box pops up. Clicking OK
would perform the callback function through ICallbackEventHandler that moves
to the appropriate record. Clicking CANCEL would just cancel the onChange
event leaving the currentrecord textbox at the new value entered.

To resolve this, I added a second, hidden textbox that also contains the
value of currentrecord. In currentrecord's onchange event, if the user
clicks CANCEL, it will transfer the value from the hidden currentrecord
textbox into the "live" currentrecord textbox.
 
Glad you got it straightened out!

--

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 

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

Back
Top