Re: Submitting a form doesn't appear to generate a new page...

"Richard Berger" <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
Graeme:

Wow.  That indeed fixed the problem.  Thank you VERY much.  But I am
not sure why or the side effects of that change - can you point me at
anything that might help?

The javascript function that was being called is included below - is
there something wrong that that javascript that I should fix, in order
to allow it to work with httpunit?

Thanks again!
RB

----javascript code---
function checkAndSubmit() {
  // If the answer is NOT correct, then inform the user
  //  and increase the incorrectGuesses count
  // Finally, when correct, submit the form and get a newProblem
  oDenominator = document.getElementById("Denominator");
  var denominator = parseInt(oDenominator.innerHTML);
  oNumerator = document.getElementById("Numerator");
  var numerator = parseInt(oNumerator.innerHTML);
  oOperationSymbol = document.getElementById("OperationSymbol");
  var operationSymbol = oOperationSymbol.innerHTML;
  var guess = document.form.Guess.value;
  // Check for typos - don't count those
  var invalidGuess = false;
  if (guess == "" || guess == null || guess == " ") {
    invalidGuess = true;
  } else if (isNaN(parseInt(guess)) ) {
       invalidGuess = true;
  } else {
    var resultCorrect = false;
    switch (operationSymbol) {
      case "+":
	resultCorrect = (numerator + denominator == guess);
	break;
      case "-":
	resultCorrect = (numerator - denominator == guess);
	break;
      case "X":
	resultCorrect = (numerator * denominator == guess);
	break;
      case "÷":
	resultCorrect = (numerator / denominator == guess);
	break;
      default:
	resultCorrect = false;
    }
  }
  if (invalidGuess) {
    oRewardText = document.getElementById("RewardText");
    if (oRewardText != null) {
      oRewardText.innerHTML="Please enter a number as your guess";
    }
    document.form.Guess.value = " ";
    document.form.Guess.focus();
    // Don't clear out rewards as this is not considered anything wrong
    return false;
  } else if (resultCorrect) {
    //alert("Correct!  " + "You only had " +
parseInt(document.form.WrongGuesses.value) + " incorrect guesses" );
    var oSpanNumSecondsElapsed =
document.getElementById("SpanNumSecondsElapsed");
    if (document.form.NumSecondsElapsed != null &&
oSpanNumSecondsElapsed != null) {
       document.form.NumSecondsElapsed.value = oSpanNumSecondsElapsed.innerHTML;
    }
    return true; // submit
  } else {
    //alert ("Sorry, but " + guess + " is not correct, please try again");
    document.form.WrongGuesses.value++;
    document.form.Guess.value = " ";
    document.form.Guess.focus();
    setWrongAnswerImageTextRewards();
    return false; //don't submit
  }
}

On 9/26/06, Graeme J Sweeney <[email protected]> wrote:
> On Tue, 26 Sep 2006, Richard Berger wrote:
>
> > Here's the situation:
> > ....DrillSgt/drillservlet?Command=NewDrillCommand - provides the page
> > drill.jsp to the user.  There are three forms on this page.  The main
> > form (named "form") allows the user to enter an answer and push
> > submit.  The form html looks like:
> >  <form name="form" method="post"
> > action="drillservlet?Command=NewProblemCommand"
> > onsubmit="return(checkAndSubmit())">
>
> <snip/>
>
> > Thanks so much for any help or pointers!
>
> What happens if you remove rhino (JavaScript) from your classpath?
>
> --
> Graeme -
> Outlook Express user? - http://home.in.tum.de/~jain/software/oe-quotefix/
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.