Hi I am having trouble with intermittent search results. For some reason the searches return the correct results and then randomly it will default to no form chosen. I have tried switching the if statements around and it does the same thing.
Home Page Code
export function finditbutton_click() {
let state = $w(“#dropdownState”).value;
local.setItem(“dropdownStateWord”, state);
let form = $w(“#dropdownForm”).value;
local.setItem(“dropdownFormWord”, form);
wixLocation.to(‘/quick-forms’);
}
Search Page Code
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import {local} from ‘wix-storage’;
import wixData from ‘wix-data’;
$w.onReady(() => {
$w(‘#dataset3’).onReady(() => {
console.log("Page Loaded");
var sameForm = local.getItem(“dropdownFormWord”);
$w(“#dropdownForm”).value = sameForm;
console.log(sameForm);
var sameState = local.getItem(“dropdownStateWord”);
$w(“#dropdownState”).value = sameState;
console.log(sameState);
search();
console.log("Search Complete");
});
});
export function finditbutton_click() {
console.log(“finditbutton clicked”);
search();
console.log(“Search Complete”);
}
function search() {
let theState = $w(“#dropdownState”).value;
let theForm = $w(“#dropdownForm”).value;
if ((theForm.length > 0) && (theState.length === 0)) {
$w(‘#text79’).show();
console.log(“No state chosen, search form”);
wixData.query(‘Forms’)
.eq(‘type’, $w(“#dropdownForm”).value)
.find()
.then(res => {
console.log("Results search start");
if (res.items.length === 0) {
console.log(“No Results”);
$w(‘#noResText’).show();
$w(‘#repeater1’).hide();
$w(‘#text28’).hide();
}
else {
$w(‘#noResText’).hide();
$w(‘#text28’).show();
$w(‘#repeater1’).show();
$w(‘#repeater1’).data = res.items;
$w(‘#text28’).text = theState;
}
});
}
else if ((theState.length > 0) && (theForm.length === 0)) {
console.log(“No form chosen, search state”);
wixData.query(‘Forms’)
.eq(‘state’, $w(“#dropdownState”).value)
.find()
.then(res => {
if (res.items.length === 0) {
console.log(“No Results”);
$w(‘#noResText’).show();
$w(‘#repeater1’).hide();
$w(‘#text28’).hide();
}
else {
$w(‘#noResText’).hide();
$w(‘#text28’).show();
$w(‘#repeater1’).show();
$w(‘#repeater1’).data = res.items;
$w(‘#text28’).text = theState;
}
});
}
else if ((theState.length > 0) && (theForm.length > 0)) {
console.log(“State and form value chosen”);
console.log(theState.length);
console.log(theState);
console.log(theForm);
wixData.query(‘Forms’)
.eq(‘state’, $w(“#dropdownState”).value)
.and(wixData.query(‘Forms’).eq(‘type’, $w(“#dropdownForm”).value))
.find()
.then(res => {
console.log(“Results search start”);
if (res.items.length === 0) {
console.log(“No Results”);
$w(‘#noResText’).show();
$w(‘#repeater1’).hide();
$w(‘#text28’).hide();
}
else {
$w(‘#noResText’).hide();
$w(‘#text28’).show();
$w(‘#repeater1’).show();
$w(‘#repeater1’).data = res.items;
$w(‘#text28’).text = theState;
}
});
}
else {
$w(‘#text28’).text = (“Please choose a state and form”)
$w(‘#repeater1’).hide();
}
local.removeItem (“dropdownFormWord”);
local.removeItem(“dropdownStateWord”);
}
Here is console log:
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
null
null
Search Complete
finditbutton clicked
State and form value chosen
7
Alabama
Bio Card
Search Complete
Results search start
No Results
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the HOME page. To debug this code, open mainPage.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Search Complete
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the HOME page. To debug this code, open mainPage.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Power of Attorney (Durable)
Georgia
State and form value chosen
7
Georgia
Power of Attorney (Durable)
Search Complete
Results search start
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the FORMS page. To debug this code, open c6thj.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Power of Attorney (Durable)
Georgia
No form chosen, search state
Search Complete
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the FORMS page. To debug this code, open c6thj.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Living Will
Georgia
State and form value chosen
7
Georgia
Living Will
Search Complete
Results search start
No Results
finditbutton clicked
State and form value chosen
7
Georgia
Power of Attorney (Durable)
Search Complete
Results search start
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the FORMS page. To debug this code, open c6thj.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Living Will
Georgia
State and form value chosen
7
Georgia
Living Will
Search Complete
Results search start
No Results
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the FORMS page. To debug this code, open c6thj.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Power of Attorney (Durable)
Georgia
State and form value chosen
7
Georgia
Power of Attorney (Durable)
Search Complete
Results search start
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the FORMS page. To debug this code, open c6thj.js in Developer Tools.
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Quick Forms page. To debug this code, open sxtpl.js in Developer Tools.
Page Loaded
Living Will
Georgia
No form chosen, search state
Search Complete