ssn
ssn

Reputation: 2711

elements with "display: none" remain visible

As I mentioned in the topic, even-though I have set the style to not display a particular part of the code given below, it still appears on the page. Should I be including the part of the code in a separate table? Please give your suggestions on what the problem could be.

<div id="submit">
<table
    style="font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif"
    ; border="0" cellpadding="5" cellspacing="0" align="center">

    <form id="frm" name="frm" action="http://app1/submitProxy.php"
        method="POST" enctype="multipart/form-data">
        <tr>
            <th colspan="2" bgcolor="#004276"><font color="white">
                    Submit a File 
            </th>
        </tr>
        <tr>
            <td>File:</td>
            <td><input name="upfile" type="file" value="">
            </td>
        </tr>
        <input type="hidden" name="email" readonly="readonly"
            value="<%=user.getUserName()%>" /> <input type="hidden"
            name="reanalyze" value="true" />
        <tr>
            <td>Case or Reference Number:</td>
            <td><input type="text" name="caseno" value="${caseno}" /></td>
        </tr>
<%--            <tr>
            <td>Date acquired:</td>
            <td><input type="text" name="acq" id="acq" readonly="readonly"
                value="${document.frm.acq}" /><strong><a href="#"
                    onclick="cal1.select(document.frm.acq,'anchor1','MM/dd/yyyy'); return false;"
                    title="cal1.select(document.frm.acq,'anchor1','MM/dd/yyyy'); return false;"
                    name="anchor1" id="anchor1"><font face="Helvetica,sans-serif">
                            SELECT</font> </a> </strong></td>
        </tr>
        <tr>
            <td>Type of system acquired from:</td>
            <td><input type="text" name="systemAcquired"
                value="${systemAcquired}" /></td>
        </tr> --%>
        <tr>
            <td>Obtained via:</td>
            <td></td>
        </tr>
        <tr>
            <td><dd>Search Warrant:</dd></td>
            <td><input type="checkbox" name="searchWarrant"
                onclick="showhidefield()" value="Y">
            </td>
        </tr>
<div id='hideablearea' style='display: none;'>
    <tr>
            <td>Search Warrant Number:</td>
            <td><input name="searchWarrantNumber" type="text"
                value="${searchWarrantNumber}" /> <br />
            </td>
        </tr>
        <tr>
            <td>Jurisdiction:</td>
            <td><input name="jurisdiction" type="text"
                value="${jurisdiction}" /> <br />
            </td>
        </tr>
        </div>
    <tr>
        <td><dd>Grand Jury:</dd></td>
        <td><input type="checkbox" name="grandJury" value="Y"
            onclick="checkGrandJury()">
        </td>
    </tr>
    <tr>
        <td><dd>Found in the wild:</dd>
        </td>
        <td><input type="checkbox" name="foundInTheWild" value="Y"
            onclick="checkFoundInTheWild()">
        </td>
    </tr>
    <tr>
        <td><dd>Email:</dd></td>
        <td><input type="checkbox" name="obtainedEmail" value="Y"
            onclick="checkObtainedEmail()">
        </td>
    </tr>
    <tr>
        <td><dd>Other:</dd></td>
        <td><input type="checkbox" name="obtainedOther" value="Y"
            onclick="checkObtainedOther()">
        </td>
    </tr>
    <tr>
        <td>Environment:</td>
        <td><select name="sandboxes[]" size="1">
                <option value="00-0C-29-CF-B8-A6">VMSB1 - Windows 7</option>
                <option value="00-0C-29-0A-AB-9A">VMSB2 - Windows XP</option>
        </select>
        </td>
    </tr>
    <tr>
        <td>Comments:</td>
        <td><textarea name="notes">Add comments here...</textarea><br>

        </td>
    </tr>
    <td colspan="2">
        <center>
            <input type="submit" name="button" value="Submit"
                onclick="onSubmit()" />
        </center>
    </td>
    </form>
</table>
</div>

Upvotes: 1

Views: 5437

Answers (5)

ssn
ssn

Reputation: 2711

Thank you for you help. I was for some reason not able to use any of your ideas. But, I found a work-around to it. I used a drop down menu for selecting the "obtained via" option. And since I wanted extra fields only when I select search warrant, I did something like the following:

<jsp:include page="template-header-menu.jsp" />



<script type="text/javascript">

function showFields(num){
    container = document.getElementById('field1GoHere');
    container.innerHTML = '';

    if(num == 1){
         container.innerHTML += '<td>Search Warrant Number:</td><td><input name="searchWarrantNumber" type="text" value="${searchWarrantNumber}" /></td>';
    }
    container = document.getElementById('field2GoHere');
    container.innerHTML = '';

    if(num == 1){
         container.innerHTML += '<td>Jurisdiction:</td><td><input name="jurisdiction" type="text" value="${jurisdiction}" /></td>';
    }

}

.
.
.
.
.

</script>

<div id="submit">
<table
    style="font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif"
    ; border="0" cellpadding="5" cellspacing="0" align="center" width=450>

    <form id="frm" name="frm" action="http://app1/submitProxy.php"
        method="POST" enctype="multipart/form-data">
.
.
.
.
.
.
.           <tr>
            <td width=450><font face="Helvetica,sans-serif">Obtained
                    via:* </font>
            </td>
            <td><select onchange="showFields(this.options[this.selectedIndex].value)">
                 <option value="0">Choose:</option>
                <option value="1">Search Warrant</option>
                <option value="2">Grand Jury</option>
                <option value="3">Found in the wild</option>
                <option value="4">Email</option>
                <option value="5">Other</option></select>
            </td>
        </tr>
        <tr id="field1GoHere"></tr>
        <tr id="field2GoHere"></tr>

    <tr>
    <td colspan="2">
        <center>
            <input type="submit" name="button" value="Submit"
                onclick="onSubmit()" />
        </center></td>
    </form>
</table>
</div>
<jsp:include page="template-bottom.jsp" />

Thus on selecting the drop down menu, the the options I wanted to hide appear and I didn't have to use the "display:none" at all.

Upvotes: 0

Code Magician
Code Magician

Reputation: 23972

you can't put table rows inside a div like that. It would be better to split your code into two tables, and hide the second.

<div id="submit">
<form id="frm" name="frm" action="http://app1/submitProxy.php"
        method="POST" enctype="multipart/form-data">
<table
    style="font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif"
    ; border="0" cellpadding="5" cellspacing="0" align="center">


        <tr>
            <th colspan="2" bgcolor="#004276"><font color="white">
                    Submit a File 
            </th>
        </tr>
        <tr>
            <td>File:</td>
            <td><input name="upfile" type="file" value="">
            </td>
        </tr>
        <input type="hidden" name="email" readonly="readonly"
            value="<%=user.getUserName()%>" /> <input type="hidden"
            name="reanalyze" value="true" />
        <tr>
            <td>Case or Reference Number:</td>
            <td><input type="text" name="caseno" value="${caseno}" /></td>
        </tr>
<%--            <tr>
            <td>Date acquired:</td>
            <td><input type="text" name="acq" id="acq" readonly="readonly"
                value="${document.frm.acq}" /><strong><a href="#"
                    onclick="cal1.select(document.frm.acq,'anchor1','MM/dd/yyyy'); return false;"
                    title="cal1.select(document.frm.acq,'anchor1','MM/dd/yyyy'); return false;"
                    name="anchor1" id="anchor1"><font face="Helvetica,sans-serif">
                            SELECT</font> </a> </strong></td>
        </tr>
        <tr>
            <td>Type of system acquired from:</td>
            <td><input type="text" name="systemAcquired"
                value="${systemAcquired}" /></td>
        </tr> --%>
        <tr>
            <td>Obtained via:</td>
            <td></td>
        </tr>
        <tr>
            <td><dd>Search Warrant:</dd></td>
            <td><input type="checkbox" name="searchWarrant"
                onclick="showhidefield()" value="Y">
            </td>
        </tr>
        </table>
        <table id='hideablearea' style="display: none; font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif"
    ; border="0" cellpadding="5" cellspacing="0" align="center">
    <tr>
            <td>Search Warrant Number:</td>
            <td><input name="searchWarrantNumber" type="text"
                value="${searchWarrantNumber}" /> <br />
            </td>
        </tr>
        <tr>
            <td>Jurisdiction:</td>
            <td><input name="jurisdiction" type="text"
                value="${jurisdiction}" /> <br />
            </td>
        </tr>
        </div>
    <tr>
        <td><dd>Grand Jury:</dd></td>
        <td><input type="checkbox" name="grandJury" value="Y"
            onclick="checkGrandJury()">
        </td>
    </tr>
    <tr>
        <td><dd>Found in the wild:</dd>
        </td>
        <td><input type="checkbox" name="foundInTheWild" value="Y"
            onclick="checkFoundInTheWild()">
        </td>
    </tr>
    <tr>
        <td><dd>Email:</dd></td>
        <td><input type="checkbox" name="obtainedEmail" value="Y"
            onclick="checkObtainedEmail()">
        </td>
    </tr>
    <tr>
        <td><dd>Other:</dd></td>
        <td><input type="checkbox" name="obtainedOther" value="Y"
            onclick="checkObtainedOther()">
        </td>
    </tr>
    <tr>
        <td>Environment:</td>
        <td><select name="sandboxes[]" size="1">
                <option value="00-0C-29-CF-B8-A6">VMSB1 - Windows 7</option>
                <option value="00-0C-29-0A-AB-9A">VMSB2 - Windows XP</option>
        </select>
        </td>
    </tr>
    <tr>
        <td>Comments:</td>
        <td><textarea name="notes">Add comments here...</textarea><br>

        </td>
    </tr>
    <td colspan="2">
        <center>
            <input type="submit" name="button" value="Submit"
                onclick="onSubmit()" />
        </center>
    </td>

</table>
</form>

Upvotes: 2

TNC
TNC

Reputation: 5386

All you have to do is put your id='hideablearea' style='display: none;' in the row(s) you're trying to hide - oh and remove the divs

Upvotes: 2

Alex Schenkel
Alex Schenkel

Reputation: 832

Arrgh, you broke the table: You inserted a 'div' tag within two table tr's, which is not valid html.

I suggest creating two separate tables, and hide the 2nd one. To make sure they have the same with, use the "width=" attribute on the table and td tags.

Or, as another approach, use "style='display:none;'" tag on each you want to hide, and toggle them by a class identification, eg like this:

<tr class="firstHidden" style="display:none;"> .....</tr>

With the right JS library (e.g. jQuery), toggling them on all at once is very simple:

$('.firstHidden').show();

Upvotes: 3

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

A DIV between TRs is invalid HTML. Put the "display:none" on the TR itself.

      </tr>
<div id='hideablearea' style='display: none;'>   <----- invalid
    <tr>

Upvotes: 8

Related Questions