Harriet
Harriet

Reputation: 1723

conditional display of an html element, using jsp

I would like to display a second password input field, based on a Boolean value, read from the database. The code to read from the database is written already, and it works. The issue I have is with conditional display of the list element. I know very little jsp - googled for answers, and came up with the following, witch is not working. code:

			<ul>
				<li><label for="username">Username</label>
					<input type="username" name="username" placeholder="username" required>
				</li>
				<li><label for="password">Password</label>
					<input type="password" name="password" placeholder="password" required>
				</li>
				<!-- conditional display of a second password field -->
				<% 
					if (@showDoublePasswords == true) { 
				%>
					<li><label for="password">Password 2</label>
						<input type="password" name="password" placeholder="password" required>
					</li>
					
				<% } %>
            </ul>

Upvotes: 6

Views: 18217

Answers (1)

Roger
Roger

Reputation: 1225

Try This

<ul>
                <li><label for="username">Username</label>
                    <input type="username" name="username" placeholder="username" required>
                </li>
                <li><label for="password">Password</label>
                    <input type="password" name="password" placeholder="password" required>
                </li>
                <!-- conditional display of a second password field -->
                <% 
                    //Remove '@' 
                    if (showDoublePasswords == true) 
                    { 
                %>
                      <li><label for="password">Password 2</label>
                          <input type="password" name="password" placeholder="password" required>
                    </li>

                <% } 
                %>
            </ul>

*

Upvotes: 15

Related Questions