Dynamically calculate table heading widths using javascript - how to? (PHP
-> javascript variable assignment)
I'm currently attempting to write a dynamic table where the heading width
is split in equal widths equally across the required number of columns
(PHP variable "$numberofcolumns").
Firstly, could someone please give me a hand popping some more code in
that would make it easy for me to calculate the table heading widths
dynamically? So far I have only got as far as turning the php variable
into a JavaScript variable $noofcolumns -> var columnno as shown below -
I'm now completely lost!
My total table width remaining to use is 80% (20% already used for a fixed
width column).
i.e.
if columnno = 3 -> table heading width = 80% / 3
if columnno = 4 -> table heading width = 80% / 4
etc...
I have tried using the calc() CSS3 function previously, but this doesn't
display correctly in a fair amount of browsers! (hence the requirement for
javaScript!) Due to this issue, it would be easier if the outcome of the
JavaScript code gave a value in pixels!
<script type="text/javascript">
var columnno = <?php echo $numberofcolumns; ?>;
</script>
Secondly, am I correct in thinking that I can retrieve the calculated
JavaScript variable (as javaScript is client side...) by using a PHP
function such as: $_REQUEST['javascript_variable_name_here']?
No comments:
Post a Comment