
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.14 KB | hits: 17 | expires: Never
getting input from last input-areas in an array of dynamically generated text inputs
var NumberOfQuestions= 10;
var questionCounter = 1;
var score=0;
//create the Problem array
var QuestionArray = [];
QuestionArray.push(0);
for (i=1; i<=NumberOfQuestions; i++){
var randomNumber = Math.floor(Math.random()*110);
QuestionArray.push(randomNumber);
}//end for loop
$(function() {
$("#ok").click(function() {
if(questionCounter <= NumberOfQuestions){
$("#ok").after("<p>" + QuestionArray[questionCounter] + "<input type='text' size='1' class='r'/></p>");
questionCounter++;}//end if
var temp = (".r").value();
$("#hg").append(temp);
});//end click function
});
});
$(function() {
$("#ok").click(function() {
var temp = $(".r").last().val();
$("#hg").append(temp);
if(questionCounter <= NumberOfQuestions){
$("#ok").after("<p>" + QuestionArray[questionCounter] + "<input type='text' size='1' class='r'/></p>");
questionCounter++;}//end if
});//end click function
});