Troubleshooting Guide
Forsta HX Platform - API Scripting Guide
Troubleshooting Guide
Problem: My code isn't running
- Check browser console (F12) for error messages
- Verify question IDs match exactly (case-sensitive)
- Ensure code is inside
$(document).ready()or at end of page - Check for typos in
f(Qid)syntax
Problem: Question won't show/hide
- Use browser inspector to check if element exists
- Verify the question ID:
console.log(f(AQ1).length) - Check if CSS is overriding visibility
- Make sure event listener is attached: add
console.log('event fired')
Problem: Getting wrong value
- For radio buttons: Use
.val()to get selected value - For checkboxes: Use
.val()to get array of selected values - Convert to number if needed:
parseInt(f(AQ1).val()) - Check for empty strings:
if(f(AQ1).val())
Debug Helper Function:
/**
* debugQuestion - Outputs comprehensive debug info for a question
* @param {string} qid - The question ID to debug
* @description Logs to console:
* - Whether the question element exists in DOM
* - Whether it's currently visible
* - Current value
* - Input type (radio, checkbox, text, etc.)
* Call from browser console: debugQuestion('AQ1')
*/
function debugQuestion(qid) {
console.log('=== Debug: ' + qid + ' ===');
console.log('Exists:', f(qid).length > 0);
console.log('Visible:', f(qid).is(':visible'));
console.log('Value:', f(qid).val());
console.log('Type:', f(qid).find('input').attr('type'));
console.log('================');
}
// Usage: debugQuestion('AQ1');
Test All Your Logic:
/**
* testSurveyLogic - Simple automated test for survey show/hide logic
* @description Runs through predefined test cases to verify that
* conditional logic works correctly. Sets values,
* triggers change events, and checks visibility.
* Logs results to console for easy debugging.
*/
function testSurveyLogic() {
console.log('Testing survey logic...');
// Test 1: Set AQ1 to "Yes"
f(AQ1).val('1').trigger('change');
console.log('Test 1 - BQ1 visible:', f(BQ1).is(':visible'));
// Test 2: Set AQ1 to "No"
f(AQ1).val('0').trigger('change');
console.log('Test 2 - BQ1 hidden:', !f(BQ1).is(':visible'));
console.log('Test 2 - BQ1 cleared:', f(BQ1).val() === '');
console.log('Testing complete!');
}
// Run in console: testSurveyLogic();