Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 22
  1. #1

    questionario a punteggio

    salve avrei bisogno di uno script in java che mi dia la possibilita di fare un questionario, dove per ogni risposta c'è un punteggio e alla fine in base alla somma dei punteggi dare una risposta .Del tipo se hai fatto da 1 a 10 sei biondo, se hai fatto da 11 a 20 sei moro e cosi via

    grazie sa darmi qualche dritta?

  2. #2
    su un aiutino

  3. #3
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Da zero? VVoVe:

    Comincia con l'esame di qualcosa di gia' esistente... per esempio http://www.html.it/jscript/giochi/giochi14.htm

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  4. #4
    ciao
    intanto ti ringrazio per la risposta, ma questo script prevede una sola risposta corretta per ogni domanda, mentre a me serve che ogni risposta abbia un punteggio diverso, potrei provare a modificare questo script ,conoscendo il javascript, ma ahime i don't know
    cmq ci provo vediamo cosa esce

  5. #5
    non c'è proprio nessuno che mi da una mano?

  6. #6
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Originariamente inviato da brucola
    non c'è proprio nessuno che mi da una mano?
    Sperando che ti piaccia....

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Untitled</title>
    <style type="text/css">
    <!--
    .badQuestionTitle {background-color:blue;color:white;font-family:verdana;font-size:12pt;font-weight:bold}
    .badAnswer        {color:black;font-family:verdana;font-size:10pt;}
    .badQuestionnaire {background-color:#ffffcc;}
    .badContainer     {background-color:#000080;}
    -->
    </style>
    
    </head>
    <body>
    <script language="JavaScript" type="text/javascript">
    <!--
    //-------------- Constants
    var yourScoreComment    = "Il tuo punteggio";
    var maxScoreComment     = "Punteggio totale";
    var answerButtonComment = "Rispondi";
    var resultComment       = "Risultato del test";
    
    
    //==============================================================================
    //------------- Questionnaires object definition
    //==============================================================================
    function questionnaireObj(questionnaireStringName,questionsNumber) {
     if (questionsNumber == null) {
      alert('Enter the questions number as a parameter');
    	return;
     } // if (questionsNumber == null)
     //----------- Questionnaire Name
     this.name         = questionnaireStringName;
     //----------- Max Score
     this.totalScore   = 0; 
     //----------- Current score
     this.currentScore = 0;
     //----------- Current question
     this.currentQuestion = 0; 
     //------------ Draw
     this.draw         = _draw;
     this.subDraw      = _subDraw;
     //------------ Next question
     this.nextQuestion = _nextQuestion;
     //------------ End
     this.end          = _end;
     //----------- Initiliazing Questions
     this.questions    = new Array(questionsNumber);
     var i = 0;
     for(i=0;i<questionsNumber;i++) {
      this.questions[i] = new questionObj(this);
     } // for(i=0;i<questionsNumber;i++)
     //--------- Initialize questionnaire result
     this.result  = new QuestionnaireResult(this);
     //--------- Creates the container
     var html0 = "";  
     html0    += "<div id='container' class='badContainer'>";
     html0    += "</div>"; 
     document.write(html0);
    } // function questionnaireObj(questionsNumber)
    
    //------------- Function draw questionnaire
    function _draw(aQuestionNumber) {
     if (aQuestionNumber == null) {
      aQuestionNumber = 0;
     } // if (aQuestionNumber == null) 
     //----------- Sets the current question
     this.currentQuestion = aQuestionNumber; 	 
     //--------- Resets container Content
     document.getElementById('container').innerHTML = "";   
     //--------- Creates the questionnaire
     var html1 = "";  
     html1    += "<div id='questionnaire' class='badQuestionnaire'>";
     html1    += "</div>"; 
     document.getElementById('container').innerHTML = html1;  
     //--------- Resets  
     document.getElementById('questionnaire').innerHTML = "";
     //--------- Creates the possible answers  
     var html2 = this.subDraw(aQuestionNumber);
     document.getElementById('questionnaire').innerHTML = html2; 
     //--------- Creates the button
     pulse = '<center><input type="button" value="'+answerButtonComment+'" onclick="'+this.name+'.nextQuestion()"></center>';
     document.getElementById('container').innerHTML += pulse; 
    } // _draw()
    
    function _subDraw(aQuestionNumber) {
      var html2  = '<center class="badQuestionTitle">'+this.questions[aQuestionNumber].questionTitle+'</center>
    ';
    	var len2   = this.questions[aQuestionNumber].questionsNum;
    	var j      = 0;
    	for (j=0;j<len2;j++) {
    	 selected = "";
    	 if (j==0) {
    	  selected = "checked";
    	 } // if (j==0)
    	 html2 +='<input type="radio" value="'+j+'" name="itemQ" id="q'+j+'"'+selected+' >'
    	 html2 +='<span class="badAnswer">'+ this.questions[aQuestionNumber].items[j]+'</span>
    ';
    	} // for (j=0;j<len2;j++)
    	return html2;
    } // function _subDraw(anElement
    
    function _nextQuestion() {
     //---------- Controls the answer
     var len2   = this.questions[this.currentQuestion].questionsNum;
     for (j=0;j<len2;j++) {
      //---------- Retrieves if radio was checked
      curRadio = document.getElementById('q'+j).checked;
    	//---------- Tests wether checked radio is the correct answer
    	if (curRadio && (j == this.questions[this.currentQuestion].goodAnswer || this.questions[this.currentQuestion].itemPoints[j] != null)) {
       //----------- Current score
    	 if (this.questions[this.currentQuestion].itemPoints[j] != null) {
        this.currentScore += this.questions[this.currentQuestion].itemPoints[j];	 
    	 } else {
        this.currentScore += this.questions[this.currentQuestion].points;
    	 } // if (this.itemPoints[this.currentQuestion] != null)	
    	} // if (curRadio && (j== this.questions[this.currentQuestion].goodAnswer)
     } // for (j=0;j<len2;j++) 
     //---------- Tests wether we reach last question
     if (this.currentQuestion+1>this.questions.length || this.questions[this.currentQuestion+1].questionTitle == "") {
      this.end();
    	return;
     } // if (this.currentQuestion+1>this.questions.length || this.questions[this.currentQuestion+1].questionTitle == "") 
     //---------- Draws the next question
     this.currentQuestion++;
     this.draw(this.currentQuestion);
    } // function _nextQuestion()
    
    function _end() {
     //--------- Resets container Content
     document.getElementById('container').innerHTML = ""; 
     var html1 = "";  
     html1    += "<div id='questionnaireResult' class='badQuestionnaire'>";
     html1    += "</div>"; 
     document.getElementById('container').innerHTML = html1;   
     //--------- Creates the result
     var html  = '<center class="badQuestionTitle">'+resultComment+'</center>
    
    ';
     html     += '<span class="badAnswer">'+yourScoreComment + ":"+this.currentScore+"</span>
    ";
     //--------- Se non si tratta di un questionnario a punteggio
     if (this.questions[0].itemPoints[0] == null) {
      html     += '<span class="badAnswer">'+maxScoreComment  + ":"+this.totalScore+"</span>
    ";    
     } // if (this.questions[0].itemPoints[0] == null)
     //--------- Risultato del punteggio
     if (this.result.index != 0) {
      html += '<span class="badAnswer">'+this.result.showResult()+"</span>
    ";
     } // if (this.result.index != 0) 
     html += '
    
    ';
     //--------- Assegnazione codice HTML
     document.getElementById('questionnaireResult').innerHTML = html; 
    } // function _end()
    
    //==============================================================================
    //------------- Questions object definition
    //==============================================================================
    function questionObj(parent) {
     this.questionTitle = "";
     this.points        = 0;
     this.questionsNum  = 0;
     this.goodAnswer    = 0;
     this.items         = new Array();
     this.itemPoints    = new Array(); 
     //------------ Methods
     this.setTitle      = _setTitle;
     this.getTitle      = _getTitle;
     this.setPoints     = _setPoints;
     this.getPoints     = _getPoints; 
     this.addAnswer     = _addAnswer;
     //------------ Parent
     this.parent        = parent; 
    } // function questionObj()
    
    //---------- Sets the title
    function _setTitle(aTitle) {
     this.questionTitle = aTitle;
     this.points        = 1;  
     //------------ Adding to total score
     this.parent.totalScore += this.points; 
    } // function _setTitle(aTitle)
    
    //---------- Gets the title
    function _getTitle() {
     return this.questionTitle;
    } // function _getTitle(aTitle)
    
    //---------- Sets the question's score
    function _setPoints(points) {
     //---------- Decrements former score
     this.parent.totalScore -= this.points
     this.points = points;
     //------------ Adding to total score
     this.parent.totalScore += this.points; 
    } // function _setPoints(points)
    
    //---------- Sets the question's score
    function _getPoints() {
     return this.points;
    } // function _getPoints(points)
    
    //---------- Adds an answer
    function _addAnswer(questionText,isGoodAnswerOrPoints) {
     if (isGoodAnswerOrPoints == true) {
       this.goodAnswer = this.questionsNum;
     } // if (isGoodAnswer == true)
     this.items[this.questionsNum] = questionText;
     if (parseInt(isGoodAnswerOrPoints) == isGoodAnswerOrPoints) {
      this.itemPoints[this.questionsNum] = isGoodAnswerOrPoints; 
     } else {
      this.itemPoints[this.questionsNum] = null; 
     } // if (parseInt(isGoodAnswerOrPoints) == isGoodAnswerOrPoints)
     this.questionsNum++
    } // function items()
    //==============================================================================
    
    //==============================================================================
    //------------- QuestionnaireResult object definition
    //==============================================================================
    function QuestionnaireResult(parent) {
     this.minValue   = new Array();
     this.maxValue   = new Array();
     this.comment    = new Array();
     this.index      = 0;
     //------------ Methods
     this.add        = _add;
     this.showResult = _drawResult;
     //------------ Parent
     this.parent   = parent;  
    } // function _report(minValue,maxValue,comment)
    
    function _add(minValue,maxValue,comment) {
     this.minValue[this.index] = minValue;
     this.maxValue[this.index] = maxValue;
     this.comment[this.index]  = comment;
     this.index++;
    } // function _add(minValue,maxValue,comment)
    
    function _drawResult() {
     len   = this.minValue.length;
     score = this.parent.currentScore
     for (i=0;i<len;i++) {
      if (this.minValue[i] <= score && score <= this.maxValue[i]) {
    	 return this.comment[i];
    	} // if (this.minValue[i] <= score && score <= this.maxValue[i])
     } // for (i=0;i<len;i++) 
    } // function _drawResult()
    
    //==============================================================================
    // uso dell'oggetto
    //==============================================================================
    //----------- definisce un questionnario di 6 questioni
    var questionnaire = new questionnaireObj('questionnaire',6);
    //---------- domanda 1
    questionnaire.questions[0].setTitle("Ultimo re di Francia");
    questionnaire.questions[0].setPoints(10);
    questionnaire.questions[0].addAnswer("Luigi XVI");
    questionnaire.questions[0].addAnswer("Luigi XVII");
    questionnaire.questions[0].addAnswer("Luigi XVIII");
    questionnaire.questions[0].addAnswer("Carlo X");
    //------------- Buona risposta
    questionnaire.questions[0].addAnswer("Luigi Filippo I",true);
    //---------- domanda 2
    questionnaire.questions[1].setTitle("Data della rivoluzione francese");
    questionnaire.questions[1].setPoints(10);
    questionnaire.questions[1].addAnswer("14 luglio 1798");
    //------------- Buona risposta
    questionnaire.questions[1].addAnswer("14 luglio 1789",true);
    questionnaire.questions[1].addAnswer("14 luglio 1790");
    questionnaire.questions[1].addAnswer("14 luglio 1799");
    questionnaire.questions[1].addAnswer("Mai");
    questionnaire.questions[1].addAnswer("Domani (forse)");
    //
    questionnaire.draw();
    
    //----------- definisce un questionnario di 6 questioni
    var q = new questionnaireObj('q',6);
    //---------- domanda 1
    q.questions[0].setTitle("Per te il massimo della cucina è....");
    //---------- secondo parametro = punteggio
    q.questions[0].addAnswer("La pizza",2);
    q.questions[0].addAnswer("Le patate frite",1);
    q.questions[0].addAnswer("Le rane alla provenzale",2);
    q.questions[0].addAnswer("Le boeuf bourguignon",3);
    q.questions[0].addAnswer("I sushi",1);
    //---------- domanda 2
    q.questions[1].setTitle("La macchina dei tuoi sogni....");
    q.questions[1].addAnswer("Lada 110",0);
    q.questions[1].addAnswer("Nuova Panda",1);
    q.questions[1].addAnswer("Lancia Ypsilon",2);
    q.questions[1].addAnswer("Un trattore della lamborghini",1);
    //---------- domanda 3
    q.questions[2].setTitle("Preferisci....");
    q.questions[2].addAnswer("Le bionde",1);
    q.questions[2].addAnswer("Le more",1);
    q.questions[2].addAnswer("Le rosse",2);
    q.questions[2].addAnswer("Tutte",3);
    //---------- Risultato
    q.result.add(2,2,"Hai 2 punti");
    q.result.add(3,5,"Hai tra 3 e 5 punti");
    q.result.add(6,999,"Hai più di 5 punti");
    
    //
    q.draw();
    
    
    //-->
    </script>
    
    </body>
    </html>

  7. #7
    e come funziona?

  8. #8
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Copialo e fallo girare !!!

  9. #9
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Ecco una nuova versione che gira con IE e Firefox

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Untitled</title>
    <style type="text/css">
    <!--
    .badQuestionTitle {background-color:blue;color:white;font-family:verdana;font-size:12pt;font-weight:bold}
    .badAnswer        {color:black;font-family:verdana;font-size:10pt;}
    .badQuestionnaire {background-color:#ffffcc;}
    .badContainer     {background-color:#000080;}
    -->
    </style>
    
    </head>
    <body>
    <script language="JavaScript" type="text/javascript">
    <!--
    //-------------- Constants
    var yourScoreComment    = "Il tuo punteggio";
    var maxScoreComment     = "Punteggio totale";
    var answerButtonComment = "Rispondi";
    var resultComment       = "Risultato del test";
    
    
    //==============================================================================
    //------------- Questionnaires object definition
    //==============================================================================
    function questionnaireObj(questionnaireStringName,questionsNumber) {
     if (questionsNumber == null) {
      alert('Enter the questions number as a parameter');
    	return;
     } // if (questionsNumber == null)
     //----------- Questionnaire Name
     this.name         = questionnaireStringName;
     //----------- Max Score / Current score / urrent question
     this.totalScore      = 0; 
     this.currentScore    = 0;
     this.currentQuestion = 0; 
     //--------- object names
     this.containerDiv        = 'container'+this.name;
     this.questionnaireDiv    = 'questionnaire'+this.name; 
     this.questionnaireResult = 'questionnaireResult'+this.name; 
     //------------ Methods
     this.draw         = _draw;
     this.subDraw      = _subDraw;
     this.nextQuestion = _nextQuestion;
     this.end          = _end;
     //----------- Initiliazing Questions
     this.questions    = new Array(questionsNumber);
     var i = 0;
     for(i=0;i<questionsNumber;i++) {
      this.questions[i] = new questionObj(this);
     } // for(i=0;i<questionsNumber;i++)
     //--------- Initialize questionnaire result
     this.result  = new QuestionnaireResult(this);
     //--------- Creates the container
     var html0 = "";  
     html0    += "<div id='"+this.containerDiv+"' class='badContainer'>";
     html0    += "</div>"; 
     document.write(html0);
    } // function questionnaireObj(questionsNumber)
    
    //------------- Function draw questionnaire
    function _draw(aQuestionNumber) {
     if (aQuestionNumber == null) {
      aQuestionNumber = 0;
     } // if (aQuestionNumber == null) 
     //----------- Sets the current question
     this.currentQuestion = aQuestionNumber; 	 
     //--------- Resets container Content
     document.getElementById(this.containerDiv).innerHTML = "";   
     //--------- Creates the questionnaire
     var html1 = "";  
     html1    += "<div id='"+this.questionnaireDiv+"' class='badQuestionnaire'>";
     html1    += "</div>"; 
     document.getElementById(this.containerDiv).innerHTML = html1;  
     //--------- Resets  
     document.getElementById(this.questionnaireDiv).innerHTML = "";
     //--------- Creates the possible answers  
     var html2 = this.subDraw(aQuestionNumber);
     document.getElementById(this.questionnaireDiv).innerHTML = html2; 
     //--------- Creates the button
     pulse = '<center><input type="button" value="'+answerButtonComment+'" onclick="'+this.name+'.nextQuestion()"></center>';
     document.getElementById(this.containerDiv).innerHTML += pulse; 
    } // _draw()
    
    function _subDraw(aQuestionNumber) {
      var html2  = '<center class="badQuestionTitle">'+this.questions[aQuestionNumber].questionTitle+'</center>
    ';
    	var len2   = this.questions[aQuestionNumber].questionsNum;
    	var j      = 0;
    	for (j=0;j<len2;j++) {
    	 selected = "";
    	 if (j==0) {
    	  selected = "checked";
    	 } // if (j==0)
    	 html2 +='<input type="radio" value="'+j+'" name="itemQ" id="q'+j+'"'+selected+' >'
    	 html2 +='<span class="badAnswer">'+ this.questions[aQuestionNumber].items[j]+'</span>
    ';
    	} // for (j=0;j<len2;j++)
    	return html2;
    } // function _subDraw(anElement
    
    function _nextQuestion() {
     //---------- Controls the answer
     var len2   = this.questions[this.currentQuestion].questionsNum;
     for (j=0;j<len2;j++) {
      //---------- Retrieves if radio was checked
      curRadio = document.getElementById('q'+j).checked;
    	//---------- Tests wether checked radio is the correct answer
    	if (curRadio && (j == this.questions[this.currentQuestion].goodAnswer || this.questions[this.currentQuestion].itemPoints[j] != null)) {
       //----------- Current score
    	 if (this.questions[this.currentQuestion].itemPoints[j] != null) {
        this.currentScore += this.questions[this.currentQuestion].itemPoints[j];	 
    	 } else {
        this.currentScore += this.questions[this.currentQuestion].points;
    	 } // if (this.itemPoints[this.currentQuestion] != null)	
    	} // if (curRadio && (j== this.questions[this.currentQuestion].goodAnswer)
     } // for (j=0;j<len2;j++) 
     //---------- Tests wether we reach last question
     if (this.currentQuestion+1>this.questions.length || this.questions[this.currentQuestion+1].questionTitle == "") {
      this.end();
    	return;
     } // if (this.currentQuestion+1>this.questions.length || this.questions[this.currentQuestion+1].questionTitle == "") 
     //---------- Draws the next question
     this.currentQuestion++;
     this.draw(this.currentQuestion);
    } // function _nextQuestion()
    
    function _end() {
     //--------- Resets container Content
     document.getElementById(this.containerDiv).innerHTML = ""; 
     var html1 = "";  
     html1    += "<div id='"+this.questionnaireResult+"' class='badQuestionnaire'>";
     html1    += "</div>"; 
     document.getElementById(this.containerDiv).innerHTML = html1;   
     //--------- Creates the result
     var html  = '<center class="badQuestionTitle">'+resultComment+'</center>
    
    ';
     html     += '<span class="badAnswer">'+yourScoreComment + ":"+this.currentScore+"</span>
    ";
     //--------- Se non si tratta di un questionnario a punteggio
     if (this.questions[0].itemPoints[0] == null) {
      html     += '<span class="badAnswer">'+maxScoreComment  + ":"+this.totalScore+"</span>
    ";    
     } // if (this.questions[0].itemPoints[0] == null)
     //--------- Risultato del punteggio
     if (this.result.index != 0) {
      html += '<span class="badAnswer">'+this.result.showResult()+"</span>
    ";
     } // if (this.result.index != 0) 
     html += '
    
    ';
     //--------- Assegnazione codice HTML
     document.getElementById(this.questionnaireResult).innerHTML = html; 
    } // function _end()
    
    //==============================================================================
    //------------- Questions object definition
    //==============================================================================
    function questionObj(parent) {
     this.questionTitle = "";
     this.points        = 0;
     this.questionsNum  = 0;
     this.goodAnswer    = 0;
     this.items         = new Array();
     this.itemPoints    = new Array(); 
     //------------ Methods
     this.setTitle      = _setTitle;
     this.getTitle      = _getTitle;
     this.setPoints     = _setPoints;
     this.getPoints     = _getPoints; 
     this.addAnswer     = _addAnswer;
     //------------ Parent
     this.parent        = parent; 
    } // function questionObj()
    
    //---------- Sets the title
    function _setTitle(aTitle) {
     this.questionTitle = aTitle;
     this.points        = 1;  
     //------------ Adding to total score
     this.parent.totalScore += this.points; 
    } // function _setTitle(aTitle)
    
    //---------- Gets the title
    function _getTitle() {
     return this.questionTitle;
    } // function _getTitle(aTitle)
    
    //---------- Sets the question's score
    function _setPoints(points) {
     //---------- Decrements former score
     this.parent.totalScore -= this.points
     this.points = points;
     //------------ Adding to total score
     this.parent.totalScore += this.points; 
    } // function _setPoints(points)
    
    //---------- Sets the question's score
    function _getPoints() {
     return this.points;
    } // function _getPoints(points)
    
    //---------- Adds an answer
    function _addAnswer(questionText,isGoodAnswerOrPoints) {
     if (isGoodAnswerOrPoints == true) {
       this.goodAnswer = this.questionsNum;
     } // if (isGoodAnswer == true)
     this.items[this.questionsNum] = questionText;
     if (parseInt(isGoodAnswerOrPoints) == isGoodAnswerOrPoints) {
      this.itemPoints[this.questionsNum] = isGoodAnswerOrPoints; 
     } else {
      this.itemPoints[this.questionsNum] = null; 
     } // if (parseInt(isGoodAnswerOrPoints) == isGoodAnswerOrPoints)
     this.questionsNum++
    } // function items()
    //==============================================================================
    
    //==============================================================================
    //------------- QuestionnaireResult object definition
    //==============================================================================
    function QuestionnaireResult(parent) {
     this.minValue   = new Array();
     this.maxValue   = new Array();
     this.comment    = new Array();
     this.index      = 0;
     //------------ Methods
     this.add        = _add;
     this.showResult = _drawResult;
     //------------ Parent
     this.parent   = parent;  
    } // function _report(minValue,maxValue,comment)
    
    function _add(minValue,maxValue,comment) {
     this.minValue[this.index] = minValue;
     this.maxValue[this.index] = maxValue;
     this.comment[this.index]  = comment;
     this.index++;
    } // function _add(minValue,maxValue,comment)
    
    function _drawResult() {
     len   = this.minValue.length;
     score = this.parent.currentScore
     for (i=0;i<len;i++) {
      if (this.minValue[i] <= score && score <= this.maxValue[i]) {
    	 return this.comment[i];
    	} // if (this.minValue[i] <= score && score <= this.maxValue[i])
     } // for (i=0;i<len;i++) 
    } // function _drawResult()
    //-->
    </script>
    
    
    Primo questionario : 
    <script language="JavaScript" type="text/javascript">
    <!--
    //==============================================================================
    // uso dell'oggetto
    //==============================================================================
    //----------- definisce un questionnario di 6 questioni
    var questionnaire = new questionnaireObj('questionnaire',6);
    //---------- domanda 1
    questionnaire.questions[0].setTitle("Ultimo re di Francia");
    questionnaire.questions[0].setPoints(10);
    questionnaire.questions[0].addAnswer("Luigi XVI");
    questionnaire.questions[0].addAnswer("Luigi XVII");
    questionnaire.questions[0].addAnswer("Luigi XVIII");
    questionnaire.questions[0].addAnswer("Carlo X");
    //------------- Buona risposta
    questionnaire.questions[0].addAnswer("Luigi Filippo I",true);
    //---------- domanda 2
    questionnaire.questions[1].setTitle("Data della rivoluzione francese");
    questionnaire.questions[1].setPoints(10);
    questionnaire.questions[1].addAnswer("14 luglio 1798");
    //------------- Buona risposta
    questionnaire.questions[1].addAnswer("14 luglio 1789",true);
    questionnaire.questions[1].addAnswer("14 luglio 1790");
    questionnaire.questions[1].addAnswer("14 luglio 1799");
    questionnaire.questions[1].addAnswer("Mai");
    questionnaire.questions[1].addAnswer("Domani (forse)");
    //--------- Stampa a video
    questionnaire.draw();
    //-->
    </script>
    
    
    
    
    
    
    Secondo questionario :
    <div style="width:400">
    <script language="JavaScript" type="text/javascript">
    <!--
    //----------- definisce un questionnario di 6 questioni
    var q = new questionnaireObj('q',6);
    //---------- domanda 1
    q.questions[0].setTitle("Per te il massimo della cucina è....");
    //---------- secondo parametro = punteggio
    q.questions[0].addAnswer("La pizza",2);
    q.questions[0].addAnswer("Le patate frite",1);
    q.questions[0].addAnswer("Le rane alla provenzale",2);
    q.questions[0].addAnswer("Le boeuf bourguignon",3);
    q.questions[0].addAnswer("I sushi",1);
    //---------- domanda 2
    q.questions[1].setTitle("La macchina dei tuoi sogni....");
    q.questions[1].addAnswer("Lada 110",0);
    q.questions[1].addAnswer("Nuova Panda",1);
    q.questions[1].addAnswer("Lancia Ypsilon",2);
    q.questions[1].addAnswer("Un trattore della lamborghini",1);
    //---------- domanda 3
    q.questions[2].setTitle("Preferisci....");
    q.questions[2].addAnswer("Le bionde",1);
    q.questions[2].addAnswer("Le more",1);
    q.questions[2].addAnswer("Le rosse",2);
    q.questions[2].addAnswer("Tutte",3);
    //---------- Risultato
    q.result.add(2,2,"Hai 2 punti");
    q.result.add(3,5,"Hai tra 3 e 5 punti");
    q.result.add(6,999,"Hai più di 5 punti");
    
    //--------- Stampa a video
    q.draw();
    
    //-->
    </script>
    </div>
    </body>
    </html>

  10. #10
    ti ringrazio di nuovo e molto ma continuo a non capire come funziona
    ecco quello che esce copiando il tuo codice e pubblicandolo
    http://www.dimora.altervista.org/prova3.htm

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.