JavaScript - Detecting if a question is visible
From All n One's bxp software Wixi
Revision as of 15:25, 1 September 2014 by Philip Lacey (talk | contribs) (Created page with "It is possible in Business Express (BeX), to show and hide questions. When performing validation it can be useful to tell if the question is currently displayed or not. A q...")
It is possible in bxp software (bxp), to show and hide questions. When performing validation it can be useful to tell if the question is currently displayed or not.
A question in bxp is surround by a table and it is this table you need to check for. Taking a sample of a simple question.
<table class="cssMaster_Table100PC" width="100%" id="tableid_1">
<tr id="tableid_1_tr" valign="top">
<td id="tableid_1_testing_3" width="0%" height="30" ></td>
<td id="tableid_1_testing_4" width="48%" height="30"><div class="Spoken">Contract Name</div></td>
<td id="tableid_1_testing_5" width="5%" height="30"></td>
<td id="tableid_1_testing_6" width="45%" height="30"><input type="text" name="strCDA_154_field_0_1" id="strCDA_154_field_0_1" value="" class="Notes" style="width:98%;" tabindex="10" onfocus="fn_Focus(this.id);" onchange="fn_Focus(this.id);" onclick="fn_Focus(this.id);" /></td>
<td id="tableid_1_testing_7" style="width:11px;" height="30"> <a href="../campaign/userCDD_Edit-details.asp?intCampaign_Id=154&ID=2&intCDA_Id=0&strInline=true&strType=Inbound"><img src="https://ww3.allnone.ie/images/main/edit_this.png" border="0" height="12" width="12" name="btn_Edit_tableid_1" id="btn_Edit_tableid_1" title="Edit this item" alt="Edit this item" /></a> </td>
<td id="tableid_1_testing_8" style="width:11px;" height="30"> </td>
</tr>
<tr id="tableid_1_tr2">
<td colspan="6"><br/></td>
</tr>
</table>
The question is strCDA_154_field_0_1 but it is contained within tableid_1.
If this question is hidden, it will be tableid_1 we need to check.
if (document.getElementById('tableid_1').style.display == 'none'){
}
else if (document.getElementById('tableid_1').style.display == 'inline-table'){
}
This functionality is very useful in validation, i.e. only validate if logic is currently showing it.