Changing values dynamically in XsltForms controls

115 views Asked by At

I'm trying to control some input values by javascript. I need to autocomplete some "not-enabled inputs" depending on some other variables.

The first try was to manipulate the DOM by getting the reference to the control, but the auto-generated html code is not well formed, do I can not use regex, or query selectors or the simple getElementById(). See this example > http://jsfiddle.net/wmzyqqja/7/

The second try was to modify the data model, but I failed trying specifying a path (I think so). Having this model:

<xf:model id="mod">
    <xf:instance id="people">
      <person name=""/>
    </xf:instance>

    <xf:instance id="tmpPerson">
      <person name=""/>
    </xf:instance>

    <xf:bind nodeset="instance('tmpPerson')/@name" readonly="true()" />
</xf:model>

I used this functions with no sucess:

function changeValue(){

    var ctx = xf_getInstance('mod', 'tmpPerson');
    console.log('ctx: ' + ctx);

    var reg = 'person';
    //      /tmpPerson/person --> null
    //      /model/instance/person --> null
    //      //model/instance/person
    //      /mod/tmpPerson/person --> null
    //      //mod/tmpPerson/person --> null
    //      /person
    var node = xf_getNode(ctx, reg); 

    console.log('node: ' + node); //NODE IS ALWAYS NULL

    xf_changeNode(
      node, 
      'New value'
    );
tri
    function xf_getNode(context, path)
    {
        return XsltForms_browser.selectSingleNode(path, context);
    }
    function xf_changeNode(node, value)
    {
        XsltForms_globals.openAction("XsltForms_change");
        XsltForms_browser.setValue(node, value || "");
        document.getElementById(XsltForms_browser.getMeta(node.ownerDocument.documentElement, "model")).xfElement.addChange(node);
        XsltForms_browser.debugConsole.write("Setvalue " + node.nodeName + " = " + value);
        XsltForms_globals.closeAction("XsltForms_change");
    }

This is the live demo > http://www.devel-open.org/XSLTForms/demo/changing-values-dynamically.xml

Any ide how can I manage that? I really need to modify the values. Thanks in advance!

1

There are 1 answers

1
Alain Couthures On BEST ANSWER

There is a namespace issue for your instances: default namespace is HTML. Please try again adding xmlns="" within them.