简体   繁体   中英

jsp page javabean dialog box

I have this:

<% if (nameBean.getTxnType().equalsIgnoreCase("Update"))
   { %>
    <TD><B>Gender: </B></TD>
    <TD><INPUT TYPE=TEXT NAME="tbGender" 
               VALUE="<%= nameBean.getGender()%>" MAXLENGTH=1 SIZE=3 ></TD>
<% if (nameBean.getGender() == nameBean.setGender())
{ %>

<script type="text/javascript"> 
alert("Alert Box"); 
</script> 

<% } %>

How can I compare setgender's value to textbox's new gender value and have a dialog box that says gender already exits do you want modify to different one (Y/N) and do the necessary task. How can I make jsp value talk with JavaScript? How is this possible?

You don't need JavaScript. You need to look into JSLT and pass beans so that you can read them by using ${object.Property} notation. This notation will allow you to use for-each loops, conditional statements etc.

Your (nameBean.getGender() == nameBean.setGender() doesn't make sense as getGender() returns true/false and setGender() is a mutator, hence it doesn't return anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM