Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 497
Harriet Avatar asked Sep 15 '15 11:09

Harriet


1 Answers

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>

*

like image 80
Kiran Choudhary Avatar answered Sep 17 '22 16:09

Kiran Choudhary