Javascript help

Okay so i think i have cracked this sort of…

i use this code to hide the second search i dont want visible:

//hides the search
$(document).on('knack-scene-render.scene_34', function(event, scene) {

  var $elementToHide = $("#view_227 > form > div.kn-submit.control.is-horizontal");
  $elementToHide.css('visibility', 'hidden');
  $("#view_227-search").css('visibility', 'hidden');

});

then i use this code to grab the searched item and send it to the second search box:

$(document).on('knack-records-render.view_203 , knack-records-render.view_200 , knack-records-render.view_201', async function(event, view, records) {

  Knack.showSpinner();

  // Find the dropdown element by its attributes or position in the DOM.
  var $dropdown = $('[data-field-key="field_142"]');

  if ($dropdown.length > 0) {
  // Get the selected option text from the dropdown.
  var siteSearch = $dropdown.find('option:selected').text();

  console.log(siteSearch);

  $("input[name='value']").val(siteSearch);
  $("input[name='value']").submit();

  Knack.hideSpinner();
});

This seem to be working okay. Its probably not the best way to do it, but it works for me. Hopefully it will help someone else… maybe

1 Like