Best way to determine XPath of form element - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Best way to determine XPath of form element

Last post 12-12-2006 09:43 AM by jkies00. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-11-2006 08:11 AM

    Best way to determine XPath of form element

    Hello,

    What's the best way to determine the XPath of a control in a form? I have a text field for example. It seems to me I should be able to right-click the text field in the design view, and be able to view the XPath somewhere in the properties dialog, but this is not the case.

    What's the best way to determine the XPath of an element in a form?
  • 12-11-2006 11:40 AM In reply to

    Re: Best way to determine XPath of form element

    For example, I'm trying to figure out the XPath of the Name attribute as pictured below:

  • 12-11-2006 02:00 PM In reply to

    Re: Best way to determine XPath of form element

    I have what I believe to be the correct XPath for the above image:

    dfs:queryFields/q:tDisc/@Name

    I was able to get it using a little trick shown on this blog:
    http://egrigg9000.com/mtpub/archives/000064.html

    I still get an error in my script, and I'm not sure why:

    Object required
    File:script.js
    Line:32


    My function is incomplete, but here is the code so far:


    function CTRL2_8::OnClick(eventObj)
    {
    // Write your code here
    var queryInputString = XDocument.DOM.selectSingleNode("/dfs:queryFields/q:tDisc/@Name").text;
    XDocument.UI.Alert(queryInputString);

    }



    Right now I'm just trying to get the user's input from the form, and show a pop-up window displaying that input. I'll build a SQL statement using the input eventually, but right now I keep on getting the object required error on this line:


    XDocument.DOM.selectSingleNode("/dfs:queryFields/q:tDisc/@Name").text;


    How can I tell if the problem is with my XPath or with my script?

  • 12-12-2006 05:23 AM In reply to

    • Stavi
    • Top 100 Contributor
    • Joined on 12-13-2005
    • Posts 95

    Re: Best way to determine XPath of form element

    You started off with 1 slash each time, that web page you posted says add 2 slashes
  • 12-12-2006 09:43 AM In reply to

    Re: Best way to determine XPath of form element

    that was it! I spent so much time trying to figure this out, and it was something so simple I overlooked. Good eye, and thanks.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.