function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shoesmanshoesman 

how to keep the value after the calculation

Hi

 

I am making Mathmatics drill, and writing the code like below, 

 

 {!RandomNumber1} + {!RandomNumber2} = X(value)

 

As you can see it, I want to show only QUESTIONS in Visualforce page, not ANSWER.

 

What I am thinking about is once I clicked the button, the answer comes out.

But if I write "X" there, the answer will be shown in this page.

 

So it would be great to pass the value from this page to another page....

 

Is that possible, if so please kindly advise me...

 

 

Thanks

bob_buzzardbob_buzzard

Can you clarify things a little - are you creating a page of questions where the user fills in answers, clicks Done and the page updates with the correct answers, or have I misunderstood your post?

 

shoesmanshoesman

bob buzzard

 

thanks for your reply,

 

 

>Can you clarify things a little - are you creating a page of questions where the user fills in answers, clicks Done and the page updates with the correct answers,

 

I havent misunderstand my post. Its just click Done and Page updates with correct answers.

 

 

whant I am trying to do is ,

 

1. shows math drill like this in the Visualforce(no answer show this page, answer will be shown next page).

ADD

Question 1 44.0 + 42.0 = 

 

 

2. clicke the "Go Answer" and shows the answer(go to page to show answer)

 

the Controller is below,

 

---------------------------------------------------   
     public double getRandomNumber1() {

          double ran1 = Math.round(Math.random()*100);
        
          return ran1;
          
     } 

-------------------------------------------------------------------------   

 (it is just a part of them)

 

 The critical problem I have is I make those numbers(44.0+42.0=) by RANDOM NUMBERS.

Doe to random numbers, I cant  keep the value(answer) to the next page which actually shows the answer.

 

But I need random numbers for some reasons, so please let me know how to solve this !!!

 

 

Help me out :smileysad:

 

bob_buzzardbob_buzzard

I would suggest that you save your random numbers to local variables and have a "showanswers" boolean.

 

Have the page output the numbers and the answers, but use the showanswers as the value of the rendered attribute on the answers.

 

When the page is initially displayed, set the showanswers to false.  Then make your button a commandButton that invokes an action to set showanswers to true and refreshes the page.  Your answers will the appear.

 

 

shoesmanshoesman

Thank you so so much for you prompt reply !!!!!

 

It seems bit difficult to me ....do you have some example with it ?

 

Anyway,I am just a beginner for this language, it should be time to learn more about. 

I'd love to try this.

 

I am appreciated:smileywink:

 

Thanks Bob!!