Forums › Forums › Search & Filter Pro › Auto Submit when input value changes
Tagged: Auto Submit, input value
- This topic has 10 replies, 3 voices, and was last updated 4 years ago by Ross.
-
Anonymous(Private) October 20, 2020 at 12:06 am #263445
Hi,
I’m wanting to have my S&F form submit when the input value changes via javascript.
For example:
$("#button").on("click", function(){ $(".sf-input-text").val("Desired Search Term"); });
When the value is changed via javascript, nothing happens. The input has to be manually typed. Is there a way to trigger the submit event after the value is changed? I tried using .trigger(“input) with no luck.
Thanks
Anonymous(Private) October 20, 2020 at 3:49 pm #263519No, I’m using an S&F widget. I’ve put together an example site here:http://holmestuned-001-site3.itempurl.com/
Click on the ‘Custom Search Term’ button to fill the S&F search bar and submit the form. Notice that the search term is not being saved.
You can manually type into the search box and everything works fine.
Ross Moderator(Private) October 22, 2020 at 1:38 pm #263732Hi Nathan
That’s odd indeed… I tested on our demo site, and it works fine.
So I thought, maybe your theme is doing something different with the input field / js events… so I tried to “blur” the field before submitting, and it seems to work?
jQuery( '#search-filter-form-15 .sf-field-search input[type="text"]' ).val("test"); jQuery( '#search-filter-form-15 .sf-field-search input[type="text"]' ).blur(); jQuery( '#search-filter-form-15' ).submit();
Thanks
Anonymous(Private) October 23, 2020 at 2:51 pm #263863Hi Ross,
I added your code to my test site. The results are the same, it’s submitting the form but the search term is not being stored.
http://holmestuned-001-site3.itempurl.com/ -
AuthorPosts