I am new to JavaScript and have been successfully using the code below with a checkbox.
function showAddress() {
var objectAddress = document.getElementById("objektadresse");
var addressToShow = document.getElementById("adresseeinblenden");
addressToShow.style.display = (objectAddress.checked) ? "" : "none";
}
<h4>
<!-- Show Address --><input id="objektadresse" onchange="showAddress()" type="checkbox" wtx-context="BBCF87B1-40E3-47D2-8436-F8C2B75940EF" /> Capture and publish object address</h4>
<p>Please enter the object address here only if it can be published.</p>
<div id="adresseeinblenden" margin-top="2em" style="display:none">
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td>
<h4>Street</h4>
</td>
<td>
<wstag class="wsTag" id="266" type="ddbf_67" widget="text">Portal Field :: street</wstag>
</td>
<td>
<h4>House Number</h4>
</td>
<td>
<wstag class="wsTag" id="275" type="ddbf_70" widget="text">Portal Field :: house number</wstag>
</td>
</tr>
</tbody>
</table>
</div>
Is there a way to replace the checkbox with the result of a database query (such as text, "yes", or "no")?
The
<div id="adresseeinblenden"...>
should be visible if the result is "yes" and hidden if the result is "no".
The field delivering the result appears as follows:
<wstag class="wsTag" id="5853" type="ddbf_197" widget="select">Portal Field :: address display</wstag>
I don't require any onclick events, as no user action is needed to display the div.