javascript - How to show or hide a div on the basis of a java variable value -
i working in application getting variable values user end , on basis of values open , show div. taking values in scriplet , want show or hide div on basis of value. here posting , explaining code
<% user user = (user) request.getattribute(webkeys.user); int useridint = (int) user.getuserid(); list<profile> existingprofile = profilelocalserviceutil.getbyuserid(useridint); string address1 = ""; string address2 = ""; int countrycode = 0; int statecode = 0; string city = ""; string zipcode = ""; string skypeid = ""; string twitter = ""; string primaryphone = ""; string secondaryphone = ""; for(int i=0;i<existingprofile.size();i++) { address1 = existingprofile.get(i).getaddress1(); address2 = existingprofile.get(i).getaddress2(); countrycode = existingprofile.get(i).getcountryid(); statecode = existingprofile.get(i).getstate(); city = existingprofile.get(i).getcity(); zipcode = existingprofile.get(i).getzipcode(); skypeid = existingprofile.get(i).getskypeid(); twitter = existingprofile.get(i).gettwitter(); primaryphone = existingprofile.get(i).getprimaryphone(); secondaryphone = existingprofile.get(i).getsecondaryphone(); } string getinsertedstatesql = "select stateid, name state countryid="+countrycode; statement st6 = con.createstatement(); resultset rs6 = st6.executequery(getinsertedstatesql); string getselectedstatesql = "select stateid, name state countryid="+countryidonfailedvalidationint; statement st7 = con.createstatement(); resultset rs7 = st7.executequery(getselectedstatesql); //system.out.println("user state code: "+statecode); %> <div id="personalinformationdiv">
personal information
<div id="primarylabel"> <table id="personalinformation"> <tr> <th>address 1<span style='color: #ff0000; display: inline;'>*</span></th> <td><label for="address1"><%=address1 %></label></td> <td><a href="#" onclick="open_new();"><img style="border:0;" src="<%=request.getcontextpath()%>/images/edit.png" title="click edit"></a> </td> </tr> <tr> <th>address 2<span style='color: #ff0000; display: inline;'>*</span></th> <td><label for="address2"><%=address2 %></label></td> </tr> <tr> <th>city<span style='color: #ff0000; display: inline;'>*</span></th> <td><label for="city"><%=city %></label></td> </tr> <tr> <th>primary phone<span style='color: #ff0000; display: inline;'>*</span></th> <td><label for="primary phone" ><%=primaryphone %></label></td> </tr> </table> </div> <div style="display:none;"> <input type="checkbox" name="chk" id="chk"> </div> <div id="contenttoshow"> <table id="personalinformationshowhide"> <tr> <th>address 1<span style='color: #ff0000; display: inline;'>*</span></th> <td> <aui:input inlinefield="true" label="" name="address1" size="45" value="<%=address1 %>"/> </td> </tr> <tr> <th>address 2</th> <td><aui:input inlinefield="true" label="" name="address2" size="45" value="<%=address2 %>"/></td> </tr> <tr> <th>country<span style='color: #ff0000; display: inline;'>*</span></th> <td> <select id="country" name="country"> <option value="none">- select country -</option> <% while (rs5.next()) { int code = rs5.getint("code"); string country = rs5.getstring("country"); if( countrycode !=0 ){ if(validationfailed!=null){ if(validationfailed.equals("true")){ if( countryidonfailedvalidationint == code ){ %> <option value="<%=countryidonfailedvalidationint%>" selected><%=country%></option> <% }else{ %> <option value="<%=code%>"><%=country%></option> <% } } }else{ if( countrycode == code ){ %> <option value="<%=countrycode%>" selected><%=country%></option> <% }else{ %> <option value="<%=code%>"><%=country%></option> <% } } } else { if(validationfailed!=null){ if(validationfailed.equals("true")){ if( countryidonfailedvalidationint == code ){ %> <option value="<%=countryidonfailedvalidationint%>" selected><%=country%></option> <% }else{ %> <option value="<%=code%>"><%=country%></option> <% } } } else { %> <option value="<%=code%>"><%=country%></option> <% } } } %> </select> </td> </tr> <tr> <th>state</th> <td> <div id="loaddistrict"> <select name="statelist" id="statelistenglish"> <%if(statecode!=0){ if(validationfailed!=null){ if(validationfailed.equals("true")){ while (rs7.next()) { int codestate = rs7.getint("stateid"); string statename = rs7.getstring("name"); if(stateidonfailedvalidationint == codestate){ %> <option value="<%=stateidonfailedvalidationint%>" selected><%=statename%></option> <% } else {%> <option value="<%=codestate%>"><%=statename%></option> <% } } } } else { while (rs6.next()) { int codestate = rs6.getint("stateid"); string statename = rs6.getstring("name"); if( codestate == statecode ){ %> <option value="<%=statecode%>" selected><%=statename%></option> <% }else{%> <option value="<%=codestate%>"><%=statename%></option> <% } } } } else if(statecode==0){ %> <option value="none">--select state--</option> <% while (rs7.next()) { int codestate = rs7.getint("stateid"); string statename = rs7.getstring("name"); if(validationfailed.equals("true")){ if(stateidonfailedvalidationint == codestate){ %> <option value="<%=stateidonfailedvalidationint%>" selected><%=statename%></option> <% } else {%> <option value="<%=codestate%>"><%=statename%></option> <% } } } } %> </select> </div> </td> </tr> <tr> <th>city<span style='color: #ff0000; display: inline;'>*</span></th> <td><aui:input inlinefield="true" label="" name="city" size="45" value="<%=city %>"/></td> </tr> <tr> <th>zip</th> <td><aui:input inlinefield="true" label="" name="zip" size="45" value="<%=zipcode %>"/><span id="errmsg1"></span></td> </tr> <tr> <th>skype id</th> <td><aui:input inlinefield="true" label="" name="skypeid" size="45" value="<%=skypeid %>"/></td> </tr> <tr> <th>twitter</th> <td><aui:input inlinefield="true" label="" name="twitter" size="45" value="<%=twitter %>"/></td> </tr> <tr> <th>primary phone<span style='color: #ff0000; display: inline;'>*</span></th> <td><aui:input inlinefield="true" label="" name="primaryphone" size="45" value="<%=primaryphone %>"/><span id="errmsg2"></span></td> </tr> <tr> <th>secondary phone</th> <td><aui:input inlinefield="true" label="" name="secondaryphone" size="45" value="<%=secondaryphone %>"/><span id="errmsg3"></span></td> </tr> </table> <br> <table> <tr> <td align="center"> <aui:button type="submit" name="submit" value="save , continue" style="width: 160px"></aui:button> </td> <td> <aui:button type="submit" name="submit" value="close" style="width: 160px" onclick="hideform();"></aui:button> </td> </tr> </table> <aui:input type="hidden" name="redirecturl" value="<%= renderresponse.createrenderurl().tostring() %>"/>
now need want show content of contenttoshow div when values of address1, address2, city, primary phone null. how achieve that? please help.
Comments
Post a Comment