Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Selectively showing and hiding buttons  RSS feed

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some help.

I am thinking of creating a quiz application and facing one problem.

On first question I don`t have to show previous button and on last question I don`t have to show next button.
And for in between question I have to show both the buttons.
.
How can I do that in a JSP page.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Determine if you are on the first or last page, and omit the unnecessary buttons as appropriate. You'd use the JSTL conditional tags (most likely <c:if>) to make decisions.
 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maintain index of current question being displayed. If currentQuestion index == 1 then do not display Previous button. If currentquestion index == last, then do not display Next button. As Bear Bibeault explained, use JSTL to maintain if condition.
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys , I will try.
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this but its not working.
Below if test is true.

<c:if test=" ${sessionScope.quest.questionNumber!=0}" >
<input type="text" name="prev" value="Previous"/>
</c:if>

What is the problem.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not working? Please read ItDoesntWorkIsUseless.

What have you done to debug this? Does quest exist on the session? If so, does it have a proper getter for the questionNumber property? If so, does it return the correct result?
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Everything is there .

Even

<c:if test=" ${0 eq 0}" var="result">
</c:if>
<c:out value="${result}"/>

Even this print false.
It should be true.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove that leading space in your test statement. It's the little things that can make all the difference.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!