Skip to content

Instantly share code, notes, and snippets.

@MaxySpark
Last active January 15, 2026 07:28
Show Gist options
  • Select an option

  • Save MaxySpark/2d902b18bb3a9b0c9aaf3e623ab3a10b to your computer and use it in GitHub Desktop.

Select an option

Save MaxySpark/2d902b18bb3a9b0c9aaf3e623ab3a10b to your computer and use it in GitHub Desktop.
UGC Net Score Calculate
function extractFormOptionsData() {
let questions = document.querySelectorAll('[id*="grAnswerKey"][id$="_lbl_QuestionNo"]');
let answers = document.querySelectorAll('[id*="grAnswerKey"][id$="_lbl_RAnswer"]');
let data = {};
questions.forEach((row, i) => {
data[row.innerHTML]= parseInt(answers[i].innerHTML)
});
return data;
}
extractFormOptionsData();
function extractAllQuestionData() {
let tables = document.querySelectorAll('.menu-tbl');
let data = {};
tables.forEach(table => {
let rows = table.getElementsByTagName('tr');
let questionID = null;
let chosenOption = null;
for (let row of rows) {
let keyCell = row.cells[0]?.textContent.trim();
let valueCell = row.cells[1]?.textContent.trim();
if (keyCell === 'Question ID :') {
questionID = valueCell;
} else if (keyCell === 'Chosen Option :') {
chosenOption = valueCell;
}
}
if (questionID && chosenOption) {
data[questionID] = parseInt(chosenOption, 10);
}
});
return data;
}
extractAllQuestionData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment