This is some jquery that is included in every page of the website.
Each page has a form on it. This jquery is used to make the form work. All the fields on all the pages wi be in the format #8_999_1, #8_999_2 etc… BUT on each page the ‘8’ will change. It could be any number. (the page id dictates this number). So Im trying to have this script work across all forms without having to do a load of if/else statements.
I hope Ive clarified it. Its kinda hard to explain.
Could you define the value of the number in the page itself, then use a loop to create the array? So your script that you want to work across all forms would effectively use a value passed into it. Whatever generates the form could create that variable, or if the forms are hard-coded it could be too.
That first matches all elements that have an id attribute (yes, that is expensive) and then loops all of them to throw out any elements that don’t match your format (one digit_999_one or more digits)