$('td.qid').text().
The code above will determine which row the alert is refering to. Below is what the alert looks like:
You have not entered a valid Question
Please Enter in the Number of Answers you Require for this question
Please enter in a figure for Number of Marks for this Question
I want the alert to look like below:
You have errors on question number: 1
You have not entered a valid Question
Please Enter in the Number of Answers you Require for this question
Please enter in a figure for Number of Marks for this Question
My question is that where do I put “You have errors on question number” and the code $('td.qid').text() in the function below to be able to display the ‘You have errors on question number: 1’ on the top of the alert?
Below is the validation function:
var qnum = 1;
function insertQuestion(form) {
var $tbody = $('#qandatbl > tbody');
var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
var $qid = $("<td class='qid'>" + qnum + "</td>");
$tr.append($qid);
$tbody.append($tr);
$(form).find('.numberOfQuestions').val(qnum);
++qnum;
$("#questionNum").text(qnum);
}
Thanks
Let say your html page looks like this:
Then you add a jQuery code like this:
By doing this you add a click event on every then pick the text of the column with the class qid and build your message.
you can try it here: http://jsfiddle.net/franky/f956k/