I have an html table with 2 columns and 2 rows. I want the columns to stay fixed. So for example,
Row1Text Dropdown
Row2Text Textbox
Instead what is happening is the Dropwdown is shifting over. For example,
Row1Text Dropdown
Row2Text Textbox
This is happening in IE 11 and Chrome Version 35.0.1916.153. However, it works fine in IE9.
Here is the code I am using: http://jsfiddle.net/RnSXA/
.Text {
width:600px;
}
function DropdownChange(value) {
if (value == "2") {
document.getElementById("Row2").style.display = "block";
}
else {
document.getElementById("Row2").style.display = "none";
}
}
<table style="width:100%;">
<tr>
<th align="left" style="width: 15%">
Row1:
</th>
<td style="width: 85%">
<select onchange="DropdownChange(this.value)">
<option value="1">1</option>
<option value="2">2</option>
</select>
</td>
</tr>
<tr id="Row2" style="display:none;">
<th align="left" style="width: 15%">
Row2:
</th>
<td style="width: 85%">
<input type="text" class="Text"/>
</td>
</tr>
</table>
I needed to use 'display:table-row' instead of 'display:block'. This question is answered in this post:
Change your html structure to follow:
html
<table style="width:100%;">
<tr>
<th align="left" style="width: 15%">
Row1:
<select onchange="DropdownChange(this.value)">
<option value="1">1</option>
<option value="2">2</option>
</select>
</th>
<td style="width: 85%"></td>
</tr>
<tr id="Row2" style="display:none;">
<th align="left" style="width: 15%">
Row2:
</th>
<td style="width: 85%">
<input type="text" class="Text"/>
</td>
</tr>
</table>
You have to move your select inside <th>
fiddle
Related
I'm trying to hide the second table below and make it appear when customers select the debit option from the drop down menu at the top. I'm relatively new to this so any help is greatly appreciated!
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select>
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
</td>
<span style="text-align: center">
</div>
</span>
</tr>
</tbody>
</table>
Add id="table2" to your table and this CSS to start hidden:
#table2 {
visibility:hidden;
}
And add to your <select> the onchange="ShowHide(this)" every change in select call the ShowHide function.
With javascript add this function to turn visible the table if the option selected is debit:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
Online example:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
#table2 {
visibility:hidden;
}
<table width="300" height="75" border="2">
<tbody>
<tr>
<th scope="col">
<span style="font-size: 13px">Payment Method:</span>
<select id="select" onchange="ShowHide(this)">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select>
</th>
</tr>
</tbody>
</table>
<br>
<table width="300" height="300" border="2" id="table2">
<tbody>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td valign="top">
<span style="font-size: 13px">Bank Account:</span>
</td>
<td>
<textarea rows="1" cols="30"></textarea>
<span></span>
</td>
</tr>
</tbody>
</table>
function paymentChangeHandler(event) {
var value = event.target.value;
var bank = document.getElementById("bank_info");
if (value.indexOf('debit') !== -1) {
bank.style.visibility = "visible";
} else {
bank.style.visibility = "hidden";
}
}
var selector = document.getElementById("payment_method");
selector.onchange = paymentChangeHandler;
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select id="payment_method">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2" id="bank_info" style="visibility:hidden;">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
<span style="text-align: center">
</span>
</tr>
</tbody>
</table>
Add id's for payment method drop down control and bank table and add style visibility:hidden to bank table.
I know I am wrong in using tables but this seems to be the most viable option.
I am trying to align text and dropdown in the form. The problem is that the text can be one-line or two-liner and it's hard to give a relative height to it when I want to keep both of them same in the same line.
When I put in the padding for the single line for a perfect align, a text with two line-text ruins it. Can I do something relative that works for both one and two line?
HTML
<table>
<tbody>
<tr>
<td style="width: 120px;" class="level-heading">
<div style="position: absolute;">Client Name</div>
</td>
<td style="width: 120px">
<div class="level">
<select name="ctl00$MainContent$cmbClientName" id="MainContent_cmbClientName" style="width:140px;">
<option selected="selected" value="Select One">Select One</option>
</select>
</div>
</td>
<td style="width: 120px;" class="level-heading">
<div style="position: absolute;">Business Segment</div>
</td>
<td style="width: 120px">
<div class="level">
<select name="ctl00$MainContent$cmbBusinessSegment" id="MainContent_cmbBusinessSegment" style="width:140px;">
<option selected="selected" value="Select One">Select One</option>
</select>
</div>
</td>
<td style="width: 120px;" class="level-heading">Business Segment Category
</td>
<td style="width: 130px">
<div class="level">
<select name="ctl00$MainContent$cmbBusinessSubGroup" id="MainContent_cmbBusinessSubGroup" class="level-big" style="width:180px;">
<option selected="selected" value="Select One">Select One</option>
</select>
</div>
</td>
</tr>
<tr>
<td style="width: 120px;" class="level-heading">Experience Test From
</td>
<td style="width: 120px">
<div class="level">
<select name="ctl00$MainContent$cmbFrom" id="MainContent_cmbFrom" style="height:16px;width:140px;">
<option selected="selected" value="Select One">Select One</option>
</select>
</div>
</td>
<td style="width: 120px;" class="level-heading">Experience Test To
</td>
<td style="width: 120px" align="justify">
<div class="level">
<select name="ctl00$MainContent$cmbTo" id="MainContent_cmbTo" style="width:140px;">
<option selected="selected" value="Select One">Select One</option>
</select>
</div>
</td>
<td style="width: 120px">
<span id="MainContent_lblPeriodTo"></span>
</td>
<td style="width: 130px"></td>
</tr>
<tr>
<td colspan="6" style="height: 10px"></td>
</tr>
</tbody>
</table>
CSS
This is the CSS that relates to the issue mentioned above.
.level-heading {
font-size: 12px;
padding-bottom: 12px;
}
.decision-page select {
font-size: 12px;
}
.fullpage-width {
width: 896px;
}
Well, you're asking for a world of frustration on the path you're heading, but let me answer your question:
have a look at this fiddle: http://jsfiddle.net/7tyjx/
First, remove the absolute positioning
<td style="width: 120px;" class="level-heading">
<div>Client Name</div>
</td>
Second, set the vertical alignment on your td's to middle
td {
vertical-align: middle;
}
Third, remove the padding from the .level-heading
.level-heading {
font-size: 12px;
}
In the fiddle I've added some borders so you can see how the alignment is working, and given the td's a exaggerated height for the same reason.
Make life easier- try using class names to identify classes of elements and styles, and then move those styles to your stylesheet -- i.e. you've got a style called .level-heading and then you add an inline-style for width. Move that width out of your markup
.level-heading { width: 120px; }
etc...
Hello everyone I have a very strange bug - Text in select option goes in two lines see screenshot (Only in IE8 and IE7 ) Does anyone know solution ?
You can access this table on web topairlines.info and choose tab registration (Please open with IE7 or IE8 to see the bug)
http://jsfiddle.net/DVyVj/1/
<table class="form-tabs" width="780" border="0px">
<tr>
<td class="td-right"><span class="red-star">*</span>שם פרטי:</td>
<td><input style="width: 250px; height:30px;" type="text" name="#"></td>
<td class="td-right"><span class="red-star">*</span>שם משפחה:</td>
<td><input style="width: 250px; height:30px;" type="text" name="#"></td>
</tr>
<tr>
<td class="td-right">תחום עסק:</td>
<td><input style="width: 250px; height:30px;" type="text" name="#"></td>
<td class="td-right"><span class="red-star">*</span>דוא"ל:</td>
<td><input style="width: 250px; height:30px;" type="text" name="#"></td>
</tr>
<tr>
<td class="td-right"><span class="red-star">*</span>טלפון:</td>
<td class="td-left">
<div class="select-right-tabs">
<select style="width: 75px; height:34px;">
<option value="1">054</option>
<option value="2">055</option>
<option value="3">056</option>
<option value="4">057</option>
</select>
</div>
<div class="input-left-tabs">
<input style="width: 169px; height:30px;" type="text" name="#">
</div>
</td>
<td class="td-right">נייד:</td>
<td class="td-left">
<div class="select-right-tabs">
<select style="width: 75px; height:34px;">
<option value="1">054</option>
<option value="2">055</option>
<option value="3">056</option>
<option value="4">057</option>
</select>
</div>
<div class="input-left-tabs">
<input style="width: 169px; height:30px;" type="text" name="#">
</div>
</td>
</tr>
<tr>
<td class="td-right">הערות:</td>
<td colspan="3">
<textarea class="textarea-tabs"></textarea>
</td>
</tr>
<tr>
<td class="td-right"></td>
<td class="extra-table-text">
<input type="checkbox" name="#" value="#">מעוניין/ת לקבל בדוא’’ל עדכונים לגבי אירועים
</td>
<td colspan="2" class="last-obligatory td-left">* שדות חובה למילוי</td>
</tr>
<tr>
<td colspan="4" class="td-left">
<button type="button" onclick="switchImg('../img/arrow/png')">שלח</button>
</td>
</tr>
</table>
I think its due to the height is 34px; and if you do not specify explicit style it will take different default style with different line-height;
I think this will do just replace this
<select style="width: 75px; height:30px; line-height:30px;">
I have updated the fiddle, pleases refer fiddle this link,
I hope this will do :)
you might try to add white-space: pre-line; on option elements!
I'm trying to display two tables inside a container div and it works perfectly in Firefox, and does exactly what I am expecting, but in IE it shifts my second table to appear outside my div. Anyone got any ideas what the issue is that I am running into here? If I put either table in by itself there is no problem, but when I add the second table, regardless of which one come first, I get the problem.
Code for tables:
<div id="contentContainer" style="border: 1px solid black;">
<table id="filterPostingsTable" align="Left" border="0" style="width:100%;">
<tr>
<th>Status</th>
<th>PositionTitle</th>
<th>Classification</th>
<th>Location</th>
<th>Filter</th>
</tr>
<tr>
<td align="center">
<select name="filterStatus" id="filterStatus">
<option selected="selected" value="">Select Status</option>
<option value="Active">Active</option>
<option value="Interviewing">Interviewing</option>
<option value="New">New</option>
</select>
</td>
<td align="center">
<input name="filterPositionTitle" type="text" id="filterPositionTitle" />
</td>
<td align="center">
<select name="922e5a87-18fd-467f-9e7b-f4210fbd93ea" id="922e5a87-18fd-467f-9e7b-f4210fbd93ea">
<option value="0">Select One...</option>
<option value="9c2e6df7-e319-478c-b137-47eff4e4748d">Administrative</option>
<option value="78ce598b-6dad-4434-9bb5-24429c630943">Certified</option>
<option value="c75f18a4-e503-428c-8e23-83d1dac21997">Classified</option>
<option value="77232a27-2c58-4192-bbbf-1b0b493da564">Other</option>
</select>
</td>
<td align="center">
<select name="filterLocation" id="filterLocation">
<option value="Select Location">Select Location</option>
<option value="77c68429-e878-4778-b467-0d684308b188">Desert Foothills</option>
<option value="d226f2a3-02c4-40c5-b784-949c22647081">District Office</option>
</select>
</td>
<td align="center">
<input type="submit" name="filterJobs" value="Filter Postings" id="filterJobs" />
</td>
</tr>
</table>
<table id="jobPostingsTable" class="tablesorter" align="Left" border="0" style="width:100%;float: left">
<thead>
<tr>
<th></th>
<th>Status</th>
<th>Position Title</th>
<th>Classification</th>
<th>Working Location</th>
</tr>
</thead>
<tbody>
<tr id="2a62a993-fc3a-4a43-96b6-fd663a724b6e">
<td>
<input id="apply2a62a993-fc3a-4a43-96b6-fd663a724b6e" type="checkbox" name="apply2a62a993-fc3a-4a43-96b6-fd663a724b6e" />
</td>
<td>New</td>
<td valign="middle">
<span>Systems Analyst</span>
<img src="images/pdf.png" style="border-width:0px;" />
</td>
<td>Classified</td>
<td>District Office</td>
</tr>
</tbody>
</table>
</div>
Applicable CSS is as follows:
#contentContainer {
background-color:#FFFFFF;
border:1px solid #000000;
float:left;
height:auto;
margin:0;
width:1000px;
}
All tables are set to width of 100%. The buttons in the image don't really matter as they don't seem to affect the table problem whether they are there or not. Usually this sort of thing works just fine, but in IE 7 it is now rendering as follows:
If you want to float your tables, they will need a width in pixels, not percent.
I have this html table where I have one cell in the table with rowSpan = 3. so in the first column, I have 3 rows with inputs and in the second column I have a picture showing to span all 3 columns. I am trying to figure out how the browser figured out how to vertically allocate spacing for each of the rows in the first column.
I want then to be "tight" so all the empty space (if the picture is big, goes to the bottom).
But it seems like the empty space is being allocated across each row equally.
Is there anyway to change this behavior . .
Here is the table:
<table class="input" border="1">
<tbody>
<tr>
<td valign="top">G:</td>
<td valign="top">
<select id="GId" maxlength="50" name="GId">
<option></option>
<option value="2">Joe</option>
<option selected="selected" value="3">Bill</option>
</select>
</td>
<td id="imageBorder" rowspan="3" align="center">
<img class="my_img" src="http://www.example.com/image.png">
</td>
</tr>
<tr>
<td valign="top">Type:</td>
<td valign="top">
<select id="EId" maxlength="50" name="EId">
<option></option>
<option value="10"></option>
<option selected="selected" value="2">A</option>
<option value="4">C</option>
</select>
</td>
</tr>
<tr>
<td valign="top">Manager:</td>
<td valign="top">
<select id="ManagerPersonId" maxlength="50" name="ManagerPersonId">
<option></option>
<option value="204">A</option>
<option value="183">B</option>
</select>
</td>
</tr>
<tr>
<td valign="top">PictureL:</td>
<td colspan="2" valign="top">
<input id="PictureLink" maxlength="200" name="PictureLink" size="60" value="http://www.example.com/image.png" type="text">
</td>
</tr>
</tbody>
</table>
I think you want to have the first 2 rows at minimum height and if the picture is big, all the space to go on the third line. If this is the case, then put a height to the first 2 lines, something like this:
<table class="input" border="1">
<tbody>
<tr>
<td valign="top" height="1">G:</td>
<td valign="top">
<select id="GId" maxlength="50" name="GId">
<option value="2">Joe</option>
<option selected="selected" value="3">Bill</option>
</select>
</td>
<td id="imageBorder" rowspan="3" align="center"><img class="my_img" src="http://www.mysite.com/image.png"> </td>
</tr>
<tr>
<td valign="top" height="1">Type:</td>
<td valign="top">
<select id="EId" maxlength="50" name="EId">
<option value="10"></option>
<option selected="selected" value="2">A</option>
<option value="4">C</option>
</select>
</td>
</tr>
<tr>
<td valign="top">Manager:</td>
<td valign="top">
<select id="ManagerPersonId" maxlength="50" name="ManagerPersonId">
<option value="204">A</option>
<option value="183">B</option>
</select>
</td>
</tr>
<tr>
<td valign="top">PictureL:</td>
<td colspan="2" valign="top"><input id="PictureLink" maxlength="200" name="PictureLink" size="60" value="http://www.mysite.com/image.png" type="text">
</td>
</tr>
</tbody>
</table>
style the td as below to have control on the data alignment.
<table>
<tr>
<td style = "height:300;width:375;vertical-align:top;"> abc </td>
</tr>
</table>
use
<tr valign="top">...</tr>
also your html looks incomplete.
UPDATE
add style="height:100%;" on the first 2 rows so the entire extra height is transferred to the 3rd row.
<table class="input" border="1">
<tbody>
<tr style="height: 100%;">
<td valign="top">G:</td>
<td valign="top"><select id="GId" maxlength="50" name="GId">
<option></option>
<option value="2">Joe</option>
<option selected="selected" value="3">Bill</option>
</select></td>
<td id="imageBorder" rowspan="3" align="center"><img class="my_img" src="http://www.google.co.in/logos/2010/flintstones10-hp.jpg"></td>
</tr>
<tr style="height: 100%;">
<td valign="top">Type:</td>
<td valign="top"><select id="EId" maxlength="50" name="EId">
<option></option>
<option value="10"></option>
<option selected="selected" value="2">A</option>
<option value="4">C</option>
</select></td>
</tr>
<tr>
<td valign="top">Manager:</td>
<td valign="top"><select name="ManagerPersonId" maxlength="50" id="ManagerPersonId">
<option></option>
<option value="204">A</option>
<option value="183">B</option>
</select></td>
</tr>
<tr>
<td valign="top">PictureL:</td>
<td colspan="2" valign="top"><input value="http://www.mysite.com/image.png" size="60" name="PictureLink" maxlength="200" id="PictureLink" type="text"></td>
</tr>
</tbody>
</table>
You can set a fixed height for each row but the last one.
<tr style="height: 20px">
<td></td>
<td></td>
<td></td>
</tr>
<tr style="height: 20px">
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
This way all the extra space will go to the last row.