none
Submitting value on 'select' in an HTML Form WP Autocomplete dropdown List NOT hitting 'Submit' button RRS feed

  • Question

  • Below is a script I have loaded into an HTML Form Web Part Filter. It is autopopulated with list items from a list called 'Companies'. I want the list item to be submitted upon select. Right now, the user has to select the item from dropdown, and then hit the 'submit' button. Can someone show me how to do this? Thanks a lot.

    <script>  
    // Settings 
    var url = "https://<mydomain>/_vti_bin/listdata.svc/Companies()";  
    var field = "Title";  
    
    // Onload  
    $(document).ready(function () {  
        $("#mytags").autocomplete({  
            source: function (req, add) {  
                var suggestions = search(req.term, url, field);  
                add(suggestions);  
            }  
        });  
    });  
    
    
    
    // Search all the listitems by using the REST Service  
    // Value is the text that needs to be used in the query  
    // listurl is the listdata.svc url withouth the filter params  
    // field is the name of the field where the value in exists  
    function search(value, listurl, field) {  
        var coll = new Array();  
        var url =  
            listurl + "?$filter=startswith(" + field + ",'" + value + "')";  
    
        $.ajax({  
            cache: true,  
            type: "GET",  
            async: false,  
            dataType: "json",  
            url: url,  
            success: function (data) {  
                var results = data.d.results;  
                for (att in results) {  
                    var object = results[att];  
                    for (attt in object) {  
                        if (attt == field) {  
                            coll.push(object[attt]);  
                        }  
                    }  
                }  
            }  
        });  
        return coll  
    }  
    </script>  
    
    <div class="ui-widget">
      <label for="mytags"> Companies</label>
    <div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
    <input id="mytags" name="mytags" input type="text"/>
    <onchange="javascript:_SFSUBMIT_"/></div>
    
    
          

    Monday, March 27, 2017 2:58 PM

All replies

  • Hi,

    Seems your tag wrong.

    <input id="mytags" name="mytags" input type="text"/>
    
    <onchange="javascript:_SFSUBMIT_"/></div>

    Try to update as below and check.

    <input id="mytags" name="mytags" type="text" onchange="javascript:_SFSUBMIT_"/></div>

    Best Regards,

    Lee

    Tuesday, March 28, 2017 11:48 AM