Question

Using YUI3 and try appending the email part of the search value to another input field. Everything working fine but don't know how to add the email value to the new input field. Right now I just appending the value to the body.

Thanks full for any help

Here is my code:

<script type="text/javascript">
YUI().use("autocomplete", "autocomplete-highlighters","autocomplete-filters", "node"
 function (Y) {
 var anInput= Y.one('#searchUser').plug(Y.Plugin.AutoComplete, {
      minQueryLength: 0,
      scrollIntoView: true,
      circular: false,
      activateFirstItem: true,
    resultHighlighter: 'phraseMatch',
    resultFilters: 'charMatch',
    resultListLocator: 'user',
    resultTextLocator: function (result_) {
        return result_.firstname+ ' ' + result_.lastname+ ' ' +    result_.email;
      },
    source: 'http://localhost:8080/rest/user/jsonp?callback={callback}',

  });


anInput.ac.on('select', function (ev) { 

        Y.one('#email').append('<div>User Email:  ' + ev.result.raw.email + '</div>');
    }); 
    });
 </script>

And here is the HTML:

<input id="searchUser" type="text" class="search" name="searchUser" size="40" value="Enter  keywords..." onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;" >

<div id="email">
 <input id="email" type="text"  name="email" size="40"  >
</div>

Here is the problem, I can't get the email value added to the input field

Thanks for any help!

Était-ce utile?

La solution

Y.one('#email').set('value', ev.result.raw.email);

https://yuilibrary.com/yui/docs/node/properties.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top