Forums Forums Search Search Results for '.val'

Viewing 10 results - 41 through 50 (of 59 total)
  • Author
    Search Results
  • #73431

    Ross
    Keymaster

    Hey Ash

    I’ve not tried to do what you are doing exactly but in theory it should work.

    So you want to clear one field if the other field is updated?

    I think what you are doing is fine, setting .val("").. when doing this, do you see the field itself change value? If so, then all you should need to do is submit the form (which will handle the building of the new URL) – $('.searchandfilter').submit(); – this will also work for an ajax powered search form.

    What you suggested above also sounds like it might do the trick (triggering a change event after you have set the val), you might need to trigger input or change and then you would need to do it here in your example:

    jQuery('.sf-field-taxonomy-taxonomy1 select').on('change',function(){
        jQuery('.sf-field-taxonomy-taxonomy2 select').val('').trigger('change');
        
    });

    Our next major version has quite a large rewrite and will include a JS api for doing this kind of thing much more easily.

    Hope that helps

    #73386

    Anonymous
    Inactive

    One more question,
    If I set dropdown value from another filter element’s event,
    url query string remains and result is different from what I expected.

    jQuery(‘.sf-field-taxonomy-taxonomy1 select’).on(‘change’,function(){
    jQuery(‘.sf-field-taxonomy-taxonomy2 select’).val(”);
    });

    url query strings after update
    /search/?_sft_taxonomy1=xxx&_sfm_taxonomy2=yyy
    _sfm_taxonomy2 should be removed.

    #70110

    Trevor
    Participant

    The script would more likely look like this:

    <script type="text/javascript">
    jQuery(document).ready(function($){
      document.getElementById("myButton").onclick=function() {
        $('.myselectorclassname').val('hello');
      }
    });
    </script>

    Exactly what your code will look like depends on what it is you are doing and want to achieve, and stackexchange is the best place to look for examples. The way I have written the code above
    is not how WordPress would say to do it, but it generally works for me.
    If you have a results shortcode on a page, that page should put the results there, yes.

    #51682

    Anonymous
    Inactive

    Hello, I have a question , I tried to hide a field by choosing an option from a select field, but only do it once, and not do it again when I select another, I have tried with jquery “switch and on change”.

    I have a select with various states of Mexico , when I choose a state , a select field must appear with other cities of that state, but only does the first time i choose a state.

    Example

    $(".sf-field-post-meta-estado .sf-input-select").change(function(){
      var id = $(this).find("option:selected").val();
    
      switch (id){
        case "Nuevo León":
          $('.sf-field-post-meta-coahuila').hide()
          $('.sf-field-post-meta-nuevoleon').show()
          break;
        case "Coahuila":
          $('.sf-field-post-meta-nuevoleon').hide()
          $('.sf-field-post-meta-coahuila').show()
          break;
      }
    });
    

    .sf-field-post-meta-estado .sf-input-select
    is the select field of the states of mexico with options like “Nuevo León, Coahuila”

    .sf-field-post-meta-coahuila, .sf-field-post-meta-coahuila
    These are the city containers of their respective states

    How could I accomplish that?, I think some script is interfering, idk.

    cheers!

    #45395

    Trevor
    Participant

    Does the http://sustainablepackaging.valipac.be/knowledge-base/ also use the same hkb-templates/hkb-archive.php page?

    #43980

    Trevor
    Participant

    Hi. So, using javascript, this is how reset a field value (for example the length):

    jQuery(".sf-field-taxonomy-length .sf-input-select").val("");
    

    I think this is correct. I am sure if Ross sees this, he will let us know if it isn’t.

    and then to submit the form:

    jQuery("#search-filter-form-339").submit();
    
    #39906

    Anonymous
    Inactive

    Hi,

    Here is the code of the archive that i use to display results (results.php):

    http://pastebin.com/Gja1JtYq

    and here i put a screenshot of the display results tab config:

    http://www.valladolidesquelas.com/wp-content/uploads/2016/03/display_options.png

    Thanks.

    #39849

    In reply to: Group sets of fields


    Anonymous
    Inactive

    Hi Ross,

    Thanks for the update.

    I’ve come up with a work around until then, where I have a dummy text input where I want to display it, and have the value copied across to a hidden text input within the form.

    If anyone else is interested in doing it, here’s the jQuery I’m using to copy the value and update the search results.

    $('#search').on('keyup click change', function(event) {
    	$('.sf-input-text').val($('#search').val());
    	$('.searchandfilter').submit();
    });
    #39828

    Anonymous
    Inactive

    Hi Ross

    Yes that’s exactly what I mean.

    <select class="chosen-select" multiple tabindex="4" name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
    <option value=\"\"><?php echo attribute_escape(__('Properties by Title')); ?></option>
    <?php wp_get_archives('type=postbypost&format=option&post_type=property'); ?> </select>

    This works outside of S&F and I noticed you used Chosen by Havest to make the nice combo boxes – so I can do that. It would be nice if I could somehow integrate it within S&F as part of a form instead of by itself. Can I do that?

    #37190

    Anonymous
    Inactive

    yes I’ve tried something like this

    (function($) {
            var disableselect = function(){
                if ($('select[name="price"]').val()) {
                    $('select[name="part"]').prop('disabled', true);
                };
                if ($('select[name="part"]').val()) {
                    $('select[name="price"]').prop('disabled', true);
                };
            }
            $(document).ready(disableselect);
            $(document).on("sf:ajaxfinish", ".searchandfilter", disableselect);
        })(jQuery);

    and it works when you refresh page, but I need it to work on “ajaxfinish”. Am I using it properly? Is there any event after ajaxfinish? I can see it’s disabled for a moment but then enabled again.
    Any idea? Sorry, I know this is not very S&F question anymore 🙂

Viewing 10 results - 41 through 50 (of 59 total)