Extract data from text box

S

SteveC

I want to be able to extract data from text that a user enters into a text
box, and pass it into the script associated with a button click.

Is there a way to do this?
 
S

S.Y.M. Wong-A-Ton

If you're using InfoPath 2003, you can use code similar to:

var fieldValue =
XDocument.DOM.selectSingleNode("<XPath_expression_to_text_box>").text;

If you're using InfoPath 2007, you can use code similar to:

XPathNavigator nav = MainDataSource.CreateNavigator();
string fieldValue = nav.SelectSingleNode("<XPath_expression_to_text_box>",
NamespaceManager).Value;

This code should go in the Click or Clicked event of the button. Then you
can write whatever code you need to write to extract the piece of text you
need to extract from the value of the text box.
 
S

SteveC

Is there a VBscript equivalent? I'm basically ignorant in regards to coding,
and the code I want to execute I wrote in VBscript, and I don't really know
how to convert it to Jscript.
 
S

S.Y.M. Wong-A-Ton

The VBScript version does not differ much from the JScript version. Try this:

Dim fieldValue
fieldValue =
XDocument.DOM.selectSingleNode("<XPath_expression_to_text_box>").text
 

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