Need multi select combo/list box on ASP page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • usr123
    New Member
    • Feb 2010
    • 20

    Need multi select combo/list box on ASP page

    Hi,

    I need a multi select combo box on ASP page.

    Scenario: on page there is a table with few columns. In multi select box, i need all the table columns,let user select a few, and show only those columns in the table which user has selected.
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello usr123,

    What have you coded so far? Please post what you have so far so we can provide you with the assistance you’re looking for.

    Happy Coding,
    CroCrew~

    Comment

    • usr123
      New Member
      • Feb 2010
      • 20

      #3
      This shows the columns.

      Code:
      <td height="20" id= "tcol1"><b><a href="live.asp?sort=old_wkctr&filter_wo=<%=request("filter_wo")%>&filter_column=<%=request("filter_column")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">W/C</a></b></td>
                <td height="20" id= "tcol2"><b><a href="live.asp?sort=old_job&filter_wo=<%=request("filter_wo")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">W/O</a></b></td>
                <td height="20" id= "tcol3"><b><a href="live.asp?sort=old_part&filter_wo=<%=request("filter_wo")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">Part</a></b></td>
                <td height="20" id= "tcol4"><b>Description</b></td>



      Data for these columns is:

      Code:
      <td bgcolor="#FFFFFF" width="7%"><%=oRS("old_wkctr")%></td>
              <td bgcolor="#FFFFFF" nowrap><a title="<%=oRS("commentary")%>" href="javascript: popup_small('edit_commentary.asp?work_order=<%=oRS("old_job")%>&commentary=<%=oRS("commentary")%>')"><%=oRS("old_job")%></a> </td>
              <td bgcolor="#FFFFFF" nowrap><%=oRS("old_part")%></td>
              <td bgcolor="#FFFFFF" width="8%"><%=oRS("pt_desc1")%></td>

      Comment

      • usr123
        New Member
        • Feb 2010
        • 20

        #4
        i have got multi select check boxes:

        Code:
        <tr>
                    <td>
                        <input type="checkbox" name="W/C" onclick="toggleVis(this.name)" checked>W/C<input type="checkbox" name="W/O" onclick="toggleVis(this.name)" checked>W/O
                        <input type="checkbox" name="Part" onclick="toggleVis(this.name)" checked>Part<input type="checkbox" name="Description" onclick="toggleVis(this.name)" checked>Description
                    </td>
                  </tr>
        Or i can have something like:

        Code:
        <tr> 
                   <td width="20%" colspan="2">
                      <select name="filter_type" class="form_textbox" multiple = "multiple" size ="5" >
                        <option value="">-Please choose-</option>
                        <option value="old_wkctr" <%if request("filter_column") = "old_wkctr" then%>selected<%end if%>>W/C</option>
                        <option value="commentary" <%if request("filter_column") = "commentary" then%>selected<%end if%>>W/O</option>
                        <option value="old_part" <%if request("filter_column") = "old_part" then%>selected<%end if%>>Part</option>
                        <option value="pt_desc1" <%if request("filter_column") = "pt_desc1" then%>selected<%end if%>>Op</option>          
                      </select>
                    </td>
                  </tr>
        In either option, i need to check at column level if its checked(in case of checkboxes) or selected(in case of Multi select combo), i couldnt figure out so far how to do that....

        Comment

        • usr123
          New Member
          • Feb 2010
          • 20

          #5
          If its selected or if its checked, i need to make visible true or false.

          Comment

          • CroCrew
            Recognized Expert Contributor
            • Jan 2008
            • 564

            #6
            What exactly do you need to make visible or not?

            Comment

            • usr123
              New Member
              • Feb 2010
              • 20

              #7
              The columns:
              Code:
              <td height="20" id= "tcol1"><b><a href="live.asp?sort=old_wkctr&filter_wo=<%=request("filter_wo")%>&filter_column=<%=request("filter_column")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">W/C</a></b></td> 
                        <td height="20" id= "tcol2"><b><a href="live.asp?sort=old_job&filter_wo=<%=request("filter_wo")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">W/O</a></b></td> 
                        <td height="20" id= "tcol3"><b><a href="live.asp?sort=old_part&filter_wo=<%=request("filter_wo")%>&filter_op=<%=request("filter_op")%>&filter_part=<%=request("filter_part")%>&filter_type=<%=request("filter_type")%>&filter_wkctr=<%=request("filter_wkctr")%>&filter_dept=<%=request("filter_dept")%>&filter_000=<%=show_000%>&w=<%=filter_w%>&q=<%=filter_q%>&Prelim=<%=filter_Prelim%>">Part</a></b></td> 
                        <td height="20" id= "tcol4"><b>Description</b></td>
              For example: If 'W/C' is selected or checked, it should be visible otherwise not.

              Comment

              • CroCrew
                Recognized Expert Contributor
                • Jan 2008
                • 564

                #8
                Ok, here is an example of what you can do using JavaScript. First let me give some insight on what the page does and then the code.

                Function:
                ShowHideColumn (CommonFieldNam ePart, MaxRowNum, obj)

                Definition:
                {CommonFieldName Part} is the beginning part of the “name” that is shared by all of the fields/columns that this function will be updating.
                {MaxRowNum} is number of fields that this function will be updating. If there are three rows in the table then you would pass ‘3’ for the “MaxRowNum” value.
                {obj} Just always pass “this.name“ as the value. In the checkbox properties make sure that the “name” value of the check box is the same as the “CommonFieldNam ePart” value.

                Note:
                For this function to work properly an understanding that all the Columns that are going to be grouped together will need to share in a common name part for each row.

                Here is a example of the whole page at work:
                Code:
                <html>
                	<head>
                		<title>Example</title>
                		<script type="text/javascript">
                			function ShowHideColumn(CommonFieldNamePart, MaxRowNum, obj)
                			{
                				for (i = 1; i <= MaxRowNum; i++)
                				{
                					if (document.getElementById(obj).checked)
                					{
                						document.getElementById(CommonFieldNamePart + i).style.display='none';
                					}
                					else
                					{
                						document.getElementById(CommonFieldNamePart + i).style.display='';
                					}
                				}
                			}
                		</script>		
                	</head>
                	<body>
                		<p>
                			Hide Column A: <input type="checkbox" name="ColumnA" onclick="ShowHideColumn('ColumnA', 2, this.name)"><br />
                			Hide Column B: <input type="checkbox" name="ColumnB" onclick="ShowHideColumn('ColumnB', 2, this.name)"><br />
                			Hide Column C: <input type="checkbox" name="ColumnC" onclick="ShowHideColumn('ColumnC', 2, this.name)"><br />
                			Hide Column D: <input type="checkbox" name="ColumnD" onclick="ShowHideColumn('ColumnD', 2, this.name)">
                		</p>
                		
                		<table border="1" bordercolor="#000000">
                			<tr>
                				<td id="ColumnA1">Dane</td>
                				<td id="ColumnB1">Sam</td>
                				<td id="ColumnC1">Ed</td>
                				<td id="ColumnD1">Bill</td>
                			</tr>
                			<tr>
                				<td id="ColumnA2">Jurkovic</td>
                				<td id="ColumnB2">Dawwod</td>
                				<td id="ColumnC2">Kodish</td>
                				<td id="ColumnD2">Chasse’</td>
                			</tr>
                		</table>
                	</body>
                </html>
                Hope this helps,
                CroCrew~

                Comment

                Working...