js变量引用HTML中文本框的value一直出错

html中搞了几个文本框,然后js中通过变量把文本框中手工输入的值取过来,一直不成功。
下面是html的代码,要引用的是J0的value(都是阿拉伯数字)

  <table id="bg2" border="0" cellpadding="0" cellspacing="0" style="margin: 0px;background-color: #800000;">
    <tr>
    <td id="selftable" class="attribute" width="280">   
        <table class="table1" border="1" cellpadding="0" cellspacing="0" bordercolor="#0079C2" height="160" width="280">
          <tr >
            <td width="50" height="20"><span style="color:#0F0">姓名span>td>
            <td width="85" height="20">
              <span><input type="text" class="Input" id="X" size="8" style="width: 80px; height: 20px; font-size: 13pt; font-weight: 400; text-align:center;background-color:#EEEEEE" value="" name="X">span>
            td>
            <td width="50" height="20"><span style="color:#0F0">专属span>td>
            <td width="50" height="20"><span style="color:#0F0">策略span>td>
          tr>
          <tr>
            <td width="50" height="20"><span>生命span>td>
            <td id="X0" width="85" height="20"><span>0/0span>td>
            <td id="A0" width="85" height="20"><span >0span>td>
            <td width="85" height="20">
            <span><input type="text" class="Input" id="J0" size="8" style="width: 80px; height: 20px; font-size: 13pt; font-weight: 400; text-align:center;background-color:#EEEEEE" value="0" name="J0">span>
            td>
          tr>

下面是js的代码,通过cj0变量来引用,一直不成功。求帮忙指点!

var cJ0 =0;
cj0 =document.getElementById('J0').value;

html只是片段吧?
js放什么位置了?
使用表单form,input放表单中试试。

你是不是把包含代码的script标签放到头部了,要放在body的内容的后面,不然获取不到元素,另外看看你的报错信息