We help IT Professionals succeed at work.

jQuery

Robert Granlund
Robert Granlund asked
on
I want to create two functions and have them both run on the click of a single button. I'm not sure how to do that.
The code creates a loop:
<script>
START LOOP
{start_loop (foreach)}
		$(".submit_to").on("click", validate_form_{row_id});
{end loop}

Open in new window


So it would look like:
$(".submit_to").on("click", validate_form_1);
$(".submit_to").on("click", validate_form_2);
$(".submit_to").on("click", validate_form_3);

Open in new window


All three functions run when one button is clicked.
Comment
Watch Question

Owner (Aidellio)
Most Valuable Expert 2015
Commented:
just create a wrapper for all three functions

$(".submit_to").on("click", validate_form);

function validate_form() {
    validate_form1();
    validate_form2();
    validate_form3();
}

Author

Commented:
When I do this, it only completes the first one and does not activate the others.
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
I'd need to see your html and other relevant code. Specifically the validation functions.

Do you get any errors on the console?