I want to show/hide a table on clicking for which I have used a javascript function as:
function changeTableStyle(){
if(document.getElementById('incompleteMigratedTable').style.display=='none')
{
document.getElementById('incompleteMigratedTable').style.display = '';
}
else
{
document.getElementById('incompleteMigratedTable').style.display = 'none';
}
}
where style none is by default given when page loads. In other file, which is included in this one I have created the button as
<h:CommandLink id="show_details"
onclick="changeTableStyle()"
value="View"
style="margin-left: 2px;font-weight:bold;color:blue;" >
<f:ajax execute="@this"
immediate="true"
render="incompleteMigratedTable"
event="click" ajaxSingle="true"
/>
</h:CommandLink>
this functionality works perfectly but the requirement is when it shows the table, text of button should change to 'Hide' and vice-versa. Can we create a variable in javascript function and use it in h:commandLink somehow to achieve this?
style.display = ''some browsers don't like it! They want a value and throw error for an empty value. Trystyle.display = 'initial'instead