Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with JS- dynamic table cell entry

    <script language="javascript">
    function splitNumber()
    {alert("inside splitnumber");

    var x = parseInt(document.getElementById("value1").value);
    var z = x%10; /*units*/
    var y = (x - z)/10; /*tens*/
    var c = parseInt(document.getElementById("value3").value);
    var a = c%10; /*units*/
    var b = (c - a)/10; /*tens*/


    for(var i=0;i<=z;i++)
    {
    var parseInt(document.getElementById("u1").td.value);
    for(((document.getElementById("u1").td.value))=0;((document.getElementById("u1").td.value))<=i;((doc ument.getElementById("u1").td.value))++)
    {
    document.write("<td> " +document.getElementById("u1").td.value +"</td>")
    }
    }
    }
    </script>



    /*this is the code i write for generating unique values in the table cells, but it is not working*/




    <body >

    <div class="left">
    <table class="main" cellpadding="3px" cellspacing="6px">

    <tr>
    <td width="630px" height="50px" bgcolor="#ffffff">
    <table class="tens">
    <tr id="t1">
    <td value="9"></td>
    <td value="8"></td>
    <td value="7"></td>
    <td value="6"></td>
    <td value="5"></td>
    <td value="4"></td>
    <td value="3"></td>
    <td value="2"></td>
    <td value="1"></td>
    </tr>
    </table>
    </td>
    <td width="200px" height="50px" bgcolor="#ffffff">
    <table class="units">
    <tr id="u1">
    <td value="9"></td>
    <td value="8"></td>
    <td value="7"></td>
    <td value="6"></td>
    <td value="5"></td>
    <td value="4"></td>
    <td value="3"></td>
    <td value="2"></td>
    <td value="1"></td>
    </tr>
    </table>
    </td>
    </tr>

    <tr>
    <td width="630px" height="50px" bgcolor="#ffffff">
    <table class="tens">
    <tr id="t2">
    <td value="9"></td>
    <td value="8"></td>
    <td value="7"></td>
    <td value="6"></td>
    <td value="5"></td>
    <td value="4"></td>
    <td value="3"></td>
    <td value="2"></td>
    <td value="1"></td>
    </tr>
    </table>
    </td>
    <td width="200px" height="50px" bgcolor="#ffffff">
    <table class="units">
    <tr id="u2">
    <td value="9"></td>
    <td value="8"></td>
    <td value="7"></td>
    <td value="6"></td>
    <td value="5"></td>
    <td value="4"></td>
    <td value="3"></td>
    <td value="2"></td>
    <td value="1"></td>
    </tr>
    </table>
    </td>

    </tr>
    <tr>
    <td width="630px" height="50px" bgcolor="#ffffff">
    <table class="tens">
    <tr id="t3">
    <td value="9">9</td>
    <td value="8">8</td>
    <td value="7">7</td>
    <td value="6">6</td>
    <td value="5">5</td>
    <td value="4">4</td>
    <td value="3">3</td>
    <td value="2">2</td>
    <td value="1">1</td>

    </tr>
    </table>
    </td>
    <td width="200px" height="50px" bgcolor="#ffffff">
    <table class="units">
    <tr id="u3">
    <td value="9">9</td>
    <td value="8">8</td>
    <td value="7">7</td>
    <td value="6">6</td>
    <td value="5">5</td>
    <td value="4">4</td>
    <td value="3">3</td>
    <td value="2">2</td>
    <td value="1">1</td>

    </tr>
    </table>
    </td>

    </tr>
    </table>



    </div>
    <div class="right" >
    <table cellpadding="3px">
    <tr>
    <td width="5px"></td>
    <td><span class="row"><input min="0" max="99" type="number" id="value1" name="value1" value="0" onchange="javascript:addNumbers()"/></span></td>
    </tr>
    <tr>
    <td width="5px"><b style="font-size:25px; position:relative; top:18px;">+</b></td>
    <td><span class="row"><input min="0" max="99" type="number" id="value3" name="value3" value="0" onchange="javascript:addNumbers()"/></span></td></tr>
    <tr><td width="5px"></td>
    <td><span class="row" ><input style=" width:66px; position:relative; right:25px;" readonly="readonly" id="answer" name="answer" value="0" /></span></td></tr>
    </table>





    </div>
    </body>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    When posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

    See also MUST READ- How to post a JavaScript question! Para 3. What exactly is your problem?


    You don't seem to understand how to create a table. A <tr> cannot have a "value".

    Code:
    <table>
    <tr id="t2">
    <tr height="50px" bgcolor="#ffffff">
    <td width = "100px">XXX</td>
    <td width = "100px"> YYY</td>
    <td width = "100px"> ZZZ</td>
    </tr>
    </table>
    "He was a wonderful man, as was his wife." - Sports Commentator


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •