How to get the element in my table's cell?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • huzheng
    New Member
    • Nov 2010
    • 2

    #1

    How to get the element in my table's cell?

    Code:
    <html>
    <head>
    <script language="javascript" >
    function smanPromptList(objInputId){//I cut my file //short to find where is wrong.
          	var objInputCel = document.getElementById(objInputId).rows[0].cells[1];
            var objInput = objInputCel.childNodes[0]; 
            document.write(objInputCel.innerText);//I tried //this wondering if it will display"apple",but it didn't.
    }
    </script>
    </head>
    <body onload="smanPromptList('tb1')" bgcolor="#ffffff">
    <table id="tb1" width="100%" border="0" cellspacing="3%" cellpadding="3%">
      <tr>
        <td id="td0" name="td0" width="300">
          <form id="form0" name="form0" method="post" action="">
          	pv:<input type="text" name="htmlText" id="htmlText"/>
        	</form>
        </td>
        <td width="300">
          apple
        </td>
      </tr>
    </table>
    <script language="javascript" >
    	document.getElementById('htmlText').value = "";
    </script>
    </body>
    Last edited by Dormilich; Nov 22 '10, 01:57 PM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    your problem is document.write( ). if it is used after the page finished loading, it erases your whole document, including all styles and scripts.

    Comment

    • huzheng
      New Member
      • Nov 2010
      • 2

      #3
      Yeah,that will erases,and I thought it'll be apple displayed.But I just see undefined,that' s puzzling me.

      Comment

      Working...