travisowens
Well-known member
IN a dynamically (via SQL) generated survey I need to enforce a minimum on some checkbox questions. So lets say I have 10 colors and you need to "pick at least 2". Lets assume I have 3 of these questions in my survey.
Ideally, I would like the submit button onclick fire off an alert to tell the user that questions 1, 2, 3 need addressing if they dont have the minimum. I already have a CSS class that toggles to give a visual cue that the question isnt valid, but now I need to actually enforce it. (PS: server side isnt important now)
The only way I can think of doing this is to create a 3x4 array that contains (question#, checkbox name, number of checkboxes, min) .... which would look like (1, chkColor_, 10, 2). The function would take each row of the array, loop thourgh all the IDs (via chkColor + for 0 to 9) and if the min isnt met, fire an alert that says "question "+ question + " requires at least "+ min +" choices."
Is there a more efficient way to do this then sending a 3x4 array?
Ideally, I would like the submit button onclick fire off an alert to tell the user that questions 1, 2, 3 need addressing if they dont have the minimum. I already have a CSS class that toggles to give a visual cue that the question isnt valid, but now I need to actually enforce it. (PS: server side isnt important now)
The only way I can think of doing this is to create a 3x4 array that contains (question#, checkbox name, number of checkboxes, min) .... which would look like (1, chkColor_, 10, 2). The function would take each row of the array, loop thourgh all the IDs (via chkColor + for 0 to 9) and if the min isnt met, fire an alert that says "question "+ question + " requires at least "+ min +" choices."
Is there a more efficient way to do this then sending a 3x4 array?
Last edited by a moderator: