Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

How to Set column "name" in search bar but Posting the ID with the form Submission #96

Open
alexyzfr opened this issue Mar 19, 2018 · 1 comment

Comments

@alexyzfr
Copy link

Hello, Sorry for my poor english.
I've to set in the search bar the value of the column "Nome" but post the value of Column "ID" with a POST form.

This is the code:

<script> jQuery(document).ready(function(){ jQuery(".mySearch").ajaxlivesearch({ loaded_at: , token: getToken() . "'"; ?>, max_input: , onResultClick: function(e, data) { // get the index 0 (first column) value **//Here i select the column "0" which is the ID but i want to show at the user the name of the product, so the Column "1"** How can I show to the users the name but post ID value to the next step? var selectedOne = jQuery(data.selected).find('td').eq('0').text(); // set the input value jQuery('#ls_query2').val(selectedOne); jQuery('#ls_query').val(selectedOne); // hide the result jQuery("#ls_query").trigger('ajaxlivesearch:hide_result'); }, onResultEnter: function(e, data) { // do whatever you want // jQuery("#ls_query").trigger('ajaxlivesearch:search', {query: 'test'}); }, onAjaxComplete: function(e, data) { } }); }) </script>

Thanks!

@BobSynfig
Copy link

Reformating the given code:

<script>
   jQuery(document).ready(function() {
     jQuery(".mySearch").ajaxlivesearch({
       loaded_at: , 
       token: getToken() . "'"; ?>,
       max_input: ,
       onResultClick: function(e, data) {
         // get the index 0 (first column) value 
         **
         // Here i select the column "0" which is the ID
            but i want to show at the user the name of the product, so the Column "1"
         ** How can I show to the users the name but post ID value to the next step?
         var selectedOne = jQuery(data.selected).find('td').eq('0').text();
         
        // set the input value 
         jQuery('#ls_query2').val(selectedOne);
         jQuery('#ls_query').val(selectedOne);

         // hide the result 
         jQuery("#ls_query").trigger('ajaxlivesearch:hide_result');
       },
       onResultEnter: function(e, data) {
         // do whatever you want 
         // jQuery("#ls_query").trigger('ajaxlivesearch:search', {query: 'test'});
       },
       onAjaxComplete: function(e, data) {
       }
     });
   })
</script>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants