Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get query string from URL using Javascript or jQuery to populate select values?
    primarykey
    data
    text
    <p>I have 3 select or option drop lists that based on what the users selects needs to populate or select the select value of the drop list based on the query string. So I guess I need help getting the URL and query string and find out if it contains any of what the user selected to populate the select value. </p> <p>Right now my select values are not persistent when a user selects them, then submits a search. How would I keep them persistent with Javascript or jQuery? My other issue is that the user can search All options, I have that working but there is a Checkbox that places a value and the value is read to search everything. How would I, on the first page load, have that check box checked and the query string of '?search=%20%20%200' to populate the URL query string. Thanks in advance.</p> <p>Here is my current JS:</p> <pre><code>var resourceGradeId; var resourceContentId; var resourceProgramTypeId; var resourceSearchAll; $(document).ready(function() { var searchAll = '&lt;strong&gt;' + "All" + '&lt;/strong&gt;'; $('#xsltsearch_summary .dmnsSearchResultNumber:contains("0")').replaceWith(searchAll); $("#resourceSelect").click(function (event) { resourceGradeId = $('#teachersResourceSearchGrade').val(); resourceContentId = $('#teachersResourceSearchContent').val(); resourceProgramTypeId = $('#teachersResourceSearchProgramType').val(); resourceSearchAll = $('#teachersResourceSearchAll').val(); window.location.href = '/teachers/classroom-resources?search=' + resourceGradeId + ' ' + resourceContentId + ' ' + resourceProgramTypeId + ' ' + resourceSearchAll; }); $("select option").attr('disabled', false); $(":checkbox").click(function(event) { //reset values if($(":checkbox").is(":checked")){ $("#teachersResourceSearchGrade").val(''); $("#teachersResourceSearchContent").val(''); $("#teachersresourceProgramTypeId").val(''); $("#teachersResourceSearchAll").val('0'); $("select").attr('disabled', true); } else { $("#teachersResourceSearchAll").val(''); $("select").attr('disabled', false); $("select option").attr('disabled', false); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload