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())
{ %>
<s开发者_JAVA技巧cript 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.
精彩评论