hide table columns which have row span - html

i have a table with 2 rows and 4 columns.first and last td is rowspan="2".
in first column i have 2 radio buttons. when i click the first one 2nd column should hide and 3rd one should be visible and vice versa.
since it has rowspan td:nth-child(2)').show() not working properly
please help
$(document).ready(function() {
var check = $("#RadioDiv input:radio:checked").val()
if (check == 'Date Wise') {
$('#tblmenubar td:nth-child(2)').show();
$('#tblmenubar td:nth-child(3)').hide();
} else {
$('#tblmenubar td:nth-child(2)').hide();
$('#tblmenubar td:nth-child(3)').show();
}
$('#RadioDiv input').click(function() {
var checktype = $("#RadioDiv input:radio:checked").val()
// alert(checktype);
if (checktype == 'Year Wise') {
$('#tblmenubar td:nth-child(3)').show();
$('#tblmenubar td:nth-child(2)').hide();
//alert('year check');
} else {
$('#tblmenubar td:nth-child(2)').show();
$('#tblmenubar td:nth-child(3)').hide();
//alert('date check');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<div id="menubar">
<table id="tblmenubar" border="bold">
<tr>
<td align="left" rowspan="2">
<div id="RadioDiv">
<input type="radio" name="type" value="Year Wise">Year Wise
<br>
<input type="radio" name="type" value="Date Wise">Date Wise
<!-- <asp:RadioButtonList ID="rbyeardate" runat="server">
<asp:ListItem Selected="True">Year Wise</asp:ListItem>
<asp:ListItem>Date Wise</asp:ListItem>
</asp:RadioButtonList> -->
</div>
</td>
<td>Start Date:
<div style="float: right;" id='jqxDateTimeInputstart'>
</div>
</td>
<td>
Year:
</td>
<td rowspan="2">
<input id="btntrial" type="button" value="Submitt" />
</td>
</tr>
<tr>
<td>End Date:
<div style="float: right;" id='jqxDateTimeInputend'>
</div>
</td>
<td>
<asp:DropDownList ID="dlFiscalYear" runat="server">
<asp:ListItem>2013</asp:ListItem>
</asp:DropDownList>
<div style="float: left;" id="jqxDropDownListYear">
</div>
</td>
</tr>
</table>
</div>

I think your problem is not that your first and last column are rowspan="2". The rowspan attribute affects rows not columns. What happens is that your second row doesn't have 4 columns but 2. You can just add an empty invisible empty cell in the second row to compensate the number of columns before the two you want to show/hide, and, very important, in the same position. Then your :nth-child() selector will select the proper cells.
<tr>
<td style="display: none"></td>
<td>End Date:
<div style="float: right;" id='jqxDateTimeInputend'>
</div>
</td>
<td>
<asp:DropDownList ID="dlFiscalYear" runat="server">
<asp:ListItem>2013</asp:ListItem>
</asp:DropDownList>
<div style="float: left;" id="jqxDropDownListYear">
</div>
</td>
</tr>

Related

How do put multiple html elements on the same row in a td

I have this code:
<td class='bid-floor-col'>
<input type='text' class='bid-floor-input' value='foo' />
<button class='bid-floor-save'>save</button>
</td>
I would like the input and the button to appear on the same row, i.e. input on left, button on right. How do I do that?
I literally just cut and paste your into a proper HTML doc and it works by default.
<table>
<tr>
<td class='bid-floor-col'>
<input type='text' class='bid-floor-input float-left' data-id='<%=ads.id %>' value='<%= display_price_floor(ads) %>' />
<button class='bid-floor-save float-right' data-id='<%=ads.id %>'>save</button>
</td>
</tr>
</table>
Screen cap of preview. Same result in Chrome.
There are several ways, and here are 2 ways to do so:
1) Using inline-block:
<td class='bid-floor-col'>
<div style="display: block">
<input type='text' style="display: inline-block; float: left" class='bid-floor-input' data-id='<%=ads.id %>' value='<%= display_price_floor(ads) %>' />
<button class='bid-floor-save' style="display: inline-block; float: right" data-id='<%=ads.id %>'>save</button>
</div>
</td>
Reference:
https://www.w3schools.com/css/css_inline-block.asp
2) Using Grid-template:
.gridContainer {
display: grid;
width: 100%;
grid-template-columns: 1fr 1fr;
}
<td class='bid-floor-col'>
<div class='gridContainer'>
<input type='text' style=" float: left" class='bid-floor-input' data-id='<%=ads.id %>' value='<%= display_price_floor(ads) %>' />
<button class='bid-floor-save' style=" float: right" data-id='<%=ads.id %>'>save</button>
</div>
</td>
Reference:
https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns

Centered textbox with an offset label?

I have a textbox centered on a page. What I would like to have is an error label display to the right of it, if necessary, and keep the textbox centered on the page. The page contains a Panel, which is centering the entire page.
<asp:Panel ID="pnlStart" runat="server" CssClass="center">
...
...
...
<tr>
<td>
<div>
<input type="text" id="pName" name="pName" runat="server" class="pName" style="color:#7A0000;width:33%;"
value="Enter Your Name" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
<asp:Label ID="pNameValidationLabel" style="width:33%;" name="pName" runat="server" Text="*Please enter your name." class="pName" visible="false"></asp:Label>
</div>
</td>
</tr>
On page load, the textbox is centered properly. but when the visibility of the pNameValidate Label appears, it tries to force both object into the Center.
Is there a way for the textbox to be centered and the label off centered, to the right?
Many thanks for looking.
You can try and add text-align:right; to the style tag in the pName element.
I went with a table and this quickly provided me what I needed...
<tr>
<td>
<table width="100%">
<tr>
<td width="33%"> </td>
<td width="33%">
<div id="shaker">
<input type="text" id="pName" autocomplete="false" clientidmode="Static" name="pName" runat="server" class="pName"
value="Please Enter Your Name Here" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
</div>
</td>
</tr>
</table>
</td>
</tr>

I only want to display 3 table rows in my table until I hover, then I want it to display them all

I've been looking for solutions for this problem I have and so far nothing has worked.
I only want to display 3 table rows in my table until I hover, then I just want it to display them all:
My HTML:
<div id="CancelTable">
<table id="tablecancel" width="800px;">
<colgroup>
<col span="1" style="width: 850px;" />
<col span="1" style="width: 850px;" />
</colgroup>
<tr>
<td>Start Date to End Date</td>
<td>Cancel</td>
<td>Accept(True)/Decline(False)</td>
</tr>
<% Set objDBConn=S erver.CreateObject( "ADODB.Connection") objDBConn.Open "Provider=sqloledb;Data Source=*******;Initial Catalog=******;User ID=Byron;Password=Pass;" Set objDBCommand=S erver.CreateObject( "ADODB.Command") objDBCommand.ActiveConnection=o bjDBConn objDBCommand.CommandText="****" objDBCommand.CommandType=a dCmdStoredProc Set objDBRS=S erver.CreateObject( "ADODB.RecordSet") objDBRS.open objDBCommand,,adOpenForwardOnly Do until objDBRS.eof %>
<tr>
<td class="Column4Table">(
<%response.Write(objDBRS(1))%>) to (
<%response.Write(objDBRS(2))%>)</td>
<td class="Column4Table">
<input type="checkbox" name="all">
</td>
<td class="Column4Table">
<%response.Write(objDBRS(3))%>
</td>
</tr>
<% a=a+1 %>
<%objDBRS.movenext Loop Set objDBCommand=nothing objDBConn.Close Set objDBConn=nothing %>
</table>
<div id="SelectAllSubmit">
<div id="SelectAll"> <strong><i>Submit</i></strong>
</div>
<div id="Div1">
<div id="p6"><span id="Span1">Select all</span>
</div>
<input type="checkbox" onclick="toggle(this)" />
<br />
<div id="buttonsubmit6" onclick="RowRemove();"> <strong><i>Submit</i></strong>
</div>
</div>
</div>
</div>
Fiddle
Here is one way to do it:
tr {
display: none;
}
tr:nth-child(1),
tr:nth-child(2),
tr:nth-child(3) {
display: table-row;
}
table:hover tr {
display: table-row;
}
DEMO

Basic html table centering in the left td

I have a table which I'm going to try to represent this way:
-------------------------
| L1 | R1 |
------------------------
| L2 | R2 |
-------------------------
My code is as follows:
<div data-role="content" id="div1" align="top" style="padding:3 !important;" >
<table border="0" align="CENTER" cellspacing="0" width="100%" style="vertical- align: text-bottom;" >
<tr>
<td></td>
<td>
<div id="question1" class="question">
<input type="text" id="question" />
<Style>
#question{
font:5px;
font-family:verdana;
}
</style>
</div>
</td></tr><tr>
<td width="50"><img id="img2" width="40" height="36" style="float:right; margin-top: 0px;" ></td>
<td style="text-align:center;">
<div class="ui-grid-b" >
<div class="ui-block-a"><button id="button1" type="submit" data-theme="b" style="font-size:0.8em;"></button></div>
<div class="ui-block-b"><button id="button2" type="submit" data-theme="b" style="font-size:0.8em;"></button></div>
<div class="ui-block-c"><button id="button3" type="submit" data-theme="b" style="font-size:0.8em;"></button></div>
</div>
</td>
</tr>
</table>
</div>
So basically what I'm trying to do is, there is no section L1 in my table. R1 has data and so has R2. There is an image in L2. What I'm trying to do is remove the division between L1 and L2 and the image in L2 should be centered on the table and not just in the TD for L2. How do I do that?
Also the other question I have is, in the following line of code:
<input type="text" id="question" />
when the value is populated and when I view this in a mobile, the text sometimes goes to the next line. I thought textarea was the only HTML tag which has multiline. Not sure why the text here is going multi-line and how do I avoid it?
See this bit just under <table border="0"....
<tr><td></td>
Change that to
<tr>
<td width="50" rowspan="2">
<img id="img2" width="40" height="36" style="float:right; margin-top: 0px;">
</td>
And then get rid of the <td></td> that originally held that image.

HTML table Aligning and format

I have three columns in a table. 1st and 3rd column have plenty of rows. 2nd column has only row, but i want this row to be located in middle of table. I am not getting desired result.
<tr>
<td>
<div id="Usrs">
<select name="z" id="z" size="25" multiple="multiple" style="width: 200px">
<option>abc</option>
</select>
</div>
</td>
<td colspan="2" align="center" valign="middle">
Move
</td>
<td>
<div id="Usrs">
<select name="z" id="z" size="25" multiple="multiple" style="width: 200px">
<option>abc</option>
</select>
</div>
</td>
</tr>
Attached the image also. Help me where am I going wrong
Use "vertical-align:" instead of "valign:"
style="vertical-align: middle"
http://www.css4you.de/Texteigenschaften/vertical-align.html
Try to add a div or span tag, and mention the width and height in it.