ufancha ufancha - 1 year ago 59
PHP Question

how to validate a checkbox with multiple values

I have tried all i can to get a solution by googling, but couldnt get one.
i have the following php code which outputs a checkbox with multiple values, the values are from a database.

echo '<input type="checkbox" name="courses[]" value="'.$courses["id_course"].'" course-credit="'.$courses["course_credit"].'" onclick="return course_credit();"/> '.$courses["course_name"].';

when the check boxes are clicked, the javascript code inside course_credit() should run and adds up the course-credit values. i know how to go after that. but i am not sure how i can get the course-credit values.

Answer Source

This should work:


In your function course_credit(), you'll get the value between the parenthesis. So do something like:

function course_credit(value){
// your code
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download