I have some code I am trying to run in a "Run JS Function on web page" but it just returns [object Object] I am just trying to return a string... a number where one of the text boxes on the page contains '09'.
Any ideas? - thanks guys!
function ExecuteScript() {
function findTextboxContainingValue09(pattern) {
// Get all textboxes in the document
var textboxes = document.querySelectorAll('input[type="text"]');
// Loop through each textbox
for (var i = 0; i < textboxes.length; i++) {
// Check if the ID of the current textbox starts with the given pattern
if (textboxes[i].value.includes('09')) {
// Extract the number at the end of the ID
var idParts = textboxes[i].id.split('$');
var number = parseInt(idParts[idParts.length - 1]);
// Return the number if it's a valid number
if (!isNaN(number)) {
return number;
}
}
}
// If no textbox with the specified pattern is found, return null
return null;
}
// Call the function with the specified pattern
var textboxNumber = findTextboxContainingValue09('SSR_RSRCH_SCHLS_SSR_SCHOL_TYPE$');
// Log the result to see if it returns the correct number
//console.log(textboxNumber);
}