<script>
(function() {
const params = new URLSearchParams(window.location.search);
const codeValue = params.get('code');
console.log('=== DEBUG ===');
console.log('Full URL:', window.location.href);
console.log('Search string:', window.location.search);
console.log('code param value:', codeValue);
function attemptPopulate() {
// Cast a wide net - find ALL inputs on the page
const allInputs = document.querySelectorAll('input');
console.log('Total inputs found:', allInputs.length);
allInputs.forEach(function(input, i) {
console.log('Input', i, '| name:', input.name, '| id:', input.id, '| type:', input.type, '| value:', input.value);
});
// Try the specific field
const field = document.querySelector('input[name="SQF_CODE"]');
console.log('SQF_CODE field found:', field);
if (field && codeValue) {
field.value = codeValue;
field.dispatchEvent(new Event('input', { bubbles: true }));
field.dispatchEvent(new Event('change', { bubbles: true }));
console.log('Field populated with:', codeValue);
return true;
}
return false;
}
if (attemptPopulate()) return;
let attempts = 0;
const interval = setInterval(function() {
attempts++;
console.log('Polling attempt:', attempts);
if (attemptPopulate()) {
console.log('Success on attempt:', attempts);
clearInterval(interval);
}
if (attempts >= 50) {
console.log('Gave up after 50 attempts');
clearInterval(interval);
}
}, 100);
})();
</script>