[英]Dynamic grow/shrink textbox by height according to inputboxes, in HTML table design
I need little help. 我需要一些帮助。 Here is the situation that I have.
这是我的情况。 I have two columns in HTML form table design (table, tr and td elemnts).
我在HTML表格表设计中有两列(table,tr和td elemnts)。 First column is populated dynamically according to doctors (29 doctors, 30 doctors, and etc, how the query returns, so dynamic) it depends {input type=”text”}, in the second column there is a textbox field which I want to be stretched by height according to number of doctors in the first column.
根据医生动态填充第一列(29位医生,30位医生等,查询如何返回,如此动态)依赖于{input type =“text”},在第二列中有一个我想要的文本框字段根据第一栏中的医生数量,按高度拉伸。 I did some coding and made it work in FF, Chrome but it needs to also work in IE8, so I am confused and searching for better approach .
我做了一些编码,并使其在FF,Chrome中工作,但它也需要在IE8中工作,所以我很困惑,并寻找更好的方法。
Here is the code, please help me out so It looks nice and works. 这是代码,请帮助我,所以看起来很好,工作。
<?php
echo "<h3 style='color:maroon'>... Please fill in the data for XRAY EXPECTED READS & XRAY UNIT READS...</h3>";
echo "<br/><br/>";
echo "<table border='1'>";
echo
"<tr>
<td style='width:168px'><b>Radiologist</b></td>
<td><b>XRAY EXPECTED READS</b></td>
</tr>";
//echo "<tr></tr>";
foreach ($rad_ln as $k => $rl)
{
echo "<tr>";
/*Rads*/
echo "<td>";
echo "<select name='rs_$k' id='rs_$k' style='width:168px'>";
echo sprintf('<option value="%s">%s</option>',$rl->rad_id,$rl->rad_last_name);
echo "</select>";
echo "</td>";
if($i == 0)
{
//Expected unit reads
echo "<td id='xray_expected_td' rowspan='" . count((array)$rad_ln) . "'>";;
echo '<textarea class="pf_update_xray_unit_reads_data" name="xray_expected_reads_data" id="xray_expected_reads_data"></textarea>';
echo "</td>";
}
echo "</tr>";
$i++;
}
echo "</table>";
echo "<br/><br/>";
?>
Here is also the image of the problem... 这也是问题的形象......
It could work with something like this: 它可以使用这样的东西:
Get the real top position of your last input with jquery: 使用jquery获取上次输入的真正顶部位置:
var posTop=$('#yourinputid').offset().top;
var heightInpt=$('#yourinputid').height();
var heightInput=posTop+heightInpt;
$('#textareaid').height(heightInput);
? ?
I played it more around it and took some pieces from Superdrac and https://stackoverflow.com/a/8342709/779965 我在它周围玩了更多,并从Superdrac和https://stackoverflow.com/a/8342709/779965采取了一些
Here is my code that is test and it works: 这是我的代码测试,它的工作原理:
var height_last_element_rads = $('select[name^="rs"]:last').offset().top;
var height_first_element_rads = $('select[name^="rs"]:first').offset().top;
var height_text_area = height_last_element_rads - height_first_element_rads;
$('#xray_expected_reads_data').height( height_text_area );
Here are also the images: 这里也是图像:
Firebug debug Firebug调试
End result
最终结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.