Here is the JSFiddle Demo . Let me know if this is what you are looking for:
I assume that you are looking to capture the width and height of td.value . You can use offsetHeight or offsetWidth
I'm not very sure what you are trying to do, but to get the height of td.value you can do the following based on the html structure. of course, if you want to go through the whole td element and find the w / element of the class name, you will have to use a regular expression to match the element with the value as part of its class:
Your vhc_record function is blurry:
var myvalue = document.getElementsByTagName('td')[0]; //grabs the td.value element based on your html markup document.getElementById('div_vhc').style.height = myvalue.offsetHeight+'px'; //sets div_vhc height to that of td.value document.getElementById('div_vhc').style.width= myvalue.offsetWidth+'px';//sets div_vhc width to that of td.value
The changes I made to html and css, and I added some visiblity properties to make the example obvious:
<table><tr><td class="value">vehicle </td></tr></table> <input type="text" id="txt_sh_vid" onKeyPress="vhc_record()" maxlength="4"> <div id="div_vhc" class="search_form"> </div> <input type="text" id="vid" style="display:none;"> td.value { background-color:#00628B; color:#E6E6DC; height: 50px; width: 50px; } #div_vhc { position:fixed; background-color:white; display: none; border: 1px solid black; }
kjy112
source share