Jump to content
Happy Holidays! ×
Search In
  • More options...
Find results that contain...
Find results in...
Roger123

QUESTION IN HTML

Recommended Posts


0aqV8fB.png
QUESTION IN HTML

In this tutorial, I'll show you how to create an issue that you can put to your users and / or your site.

CeSHQdx.pngTutorial Credits: Click here to access

--> Questions <--


QUESTION IN HTML


1 - Code
Add this code:

<SCRIPT language="JavaScript"
        type="text/javascript">
<!--
//
// Documentation:
//   http://chami.com/tips/javascript/
//
function checkAnswer(quizForm,
                     theAnswer,
                     urlRight,
                     urlWrong)
{
  var s = "?";

  // go through the "current choices"
  // to find the selected choice.
  // radio boxes pointing to choices
  // must be named "cc"
  // change if necessary
  //
  var i = 0;
  for(;i<quizForm.elements.length;i++)
  {
    if(("cc" ==
        quizForm.elements[i].name) &&
       (quizForm.elements[i].checked))
    {
      s = quizForm.elements[i].value;
    }
  }

  // no choice was selected
  //
  if("?" == s)
  {
    alert("Please make a selection.");
    return false;
  }

  // check if we have the correct
  // choice selected
  //
  if(s == theAnswer)
  {
    alert("'"+s+"' is correct!");
    if(urlRight)
    {
    document.location.href = urlRight;
    }
  }
  else
  {
    alert("'"+s+"' is incorrect.");
    if( urlWrong )
    {
    document.location.href = urlWrong;
    }
  }

  // return "false" to indicate not to
  // submit the form.
  // change this to "true" if the form
  // "action" is valid,
  // i.e. points to a valid CGI script
  //
  return false;
}
//-->
</SCRIPT>
What is JavaScript?

<FORM method="POST"
      onSubmit="return checkAnswer(this,'B');"
>

<INPUT TYPE="RADIO" VALUE="A" NAME="cc">
A. Another name for Java<BR>

<INPUT TYPE="RADIO" VALUE="B" NAME="cc">
B. A scripting language mostly for the web<BR>

<INPUT TYPE="RADIO" VALUE="C" NAME="cc">
C. When you use Java without compiling<BR>

<INPUT TYPE="SUBMIT" VALUE="Submit Answer">

</FORM>

When you find B in onSubmit="return checkAnswer(this,'B');", change to the correct answer line.

 

  • Can I add one more line / possible answer??
    Yes, you can. Add this code: <INPUT TYPE="RADIO" VALUE="D" NAME="cc"> D. X<BR>

 

 

 


 

 

 

 

© All Themes



cyoocvq.png If you have any questions regarding this topic, please create a topic with the following title: [Question] -
QUESTION IN HTML

 

Share this post


Link to post
Share on other sites

×
×
  • Create New...