Cmd button to clear text field

K

KLee

Hello, I have two questions. First question is how do you code a clear button
to clear the text field in a form? Second question is how do you code a
button so that when user click on it it will jump to the top of the form?

Thanks in advance.

Klee
 
S

Serdal

Hi Klee,

about the fist question, the solution steps:

-create a button
-edit the button in the properties window
-after this you see an onClick event (in code)
-then write: IXMLDOMNode lTEST =
thisXDocument.DOM.selectSingleNode("/my:****/my:****/@my:****");

lTEST.text = String.Empty;

This sample Code is for C#.

Use System.XML

-That's it

I hope this helps !

Serdal
 
S

Scott L. Heim [MSFT]

Hi Klee,

When you ask about clearing a text field - are you referring to just 1 or 2
fields or to basically start with a "fresh, clean" form?

In regard to using a button to go to the top of the form - you can use the
"SelectText" method to accomplish this:

Here are a couple of examples of how you would do this depending on whether
your form is based on a database or not:

- If your form is based on a database (i.e. the Orders table from the
Northwind sample database) you would use code on the button similar to the
following:

'NOTE: This is VBScript
Dim objOrderID
Set objOrderID =
XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:Orders/@Orde
rID")
XDocument.View.SelectText objOrderID

- If you built your form simply by placing various controls on your form,
then you would have code similar to the following (this assumes there is a
field on your form named: field1)

'NOTE: This is VBScript
Dim objField1
Set objField1 = XDocument.DOM.selectSingleNode("//my:myFields/my:field1")
XDocument.View.SelectText objField1

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

KLee

Thanks for responding Scott.
I just want to clear 1 field. I don't need to start with a "fresh clean" form.

Unfortunately I'm not very familar with VBscripting. Currently I am using
script.js. Do you know the code for script.js?

Thanks again.
Klee
 
S

Scott L. Heim [MSFT]

Hi Klee,

Here are the same 2 examples using JScript:

var objOrderID =
XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:Orders/@Orde
rID");
XDocument.View.SelectText(objOrderID);

var objField1 = XDocument.DOM.selectSingleNode("//my:myFields/my:field1");
XDocument.View.SelectText(objField1);

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top