Reputation: 21
In my <div>
the id attribute is the dynamic result which is comming from the webpage.
It's like following
<div class="row" id="WC_AddressEntryForm<c:out value='_${paramPrefix}'/>_div_firstname">
so the ${paramPrefix}
value is changing dynamically.
also the few next <div>
id is having this type of codes
<div class="row"
id="WC_AddressEntryForm<c:out value='_${paramPrefix}'/>_div_lastname">
<div class="row" id="WC_AddressEntryForm<c:out value='_${paramPrefix}'/>_div_1" >
and few more similar to this.
My requirement is to hide the div when ever the ${paramPrefix}
value is user
for all those <div>
previously written
So what is the way to achieve it??
Thanks a lot & Happy new Year
Upvotes: 0
Views: 3689
Reputation: 19327
Just put this JS code on the after the target element code
<div class="row" id="WC_AddressEntryForm<c:out value='_${paramPrefix}'/>_div_firstname">
<script>
document.getElementById('WC_AddressEntryFormuser_div_firstname').style.visibility = 'hidden';
</script>
or if you really want to remove the allocated space of the div you can use the display
css attribute and set it to none
<script>
document.getElementById('WC_AddressEntryFormuser_div_firstname').style.display = 'none';
</script>
Ok so it seems _${paramPrefix}
to contain dynamic values well the thing you can do is this
<script>
var user = "<c:out value='_${paramPrefix}'/>";
if(user != ""){ //hide when user variable contains something
document.getElementById('WC_AddressEntryForm'+ user +'_div_firstname').style.display = 'none';
//you can hide other elements here...
}
</script>
well this would change as your requirement changes
Reference: http://rakibulislam.wordpress.com/2008/06/11/changing-css-property-using-javascript/
Upvotes: 1
Reputation: 2349
Try this -
<%
if (! paramPrefix.equals("User")) {
%>
<div class="row" id="WC_AddressEntryForm<c:out value='_${paramPrefix}'/>_div_firstname">
<% } %>
Upvotes: 1