Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-21-2010, 10:01 AM   PM User | #1
writetoamrutha
New to the CF scene

 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
writetoamrutha is an unknown quantity at this point
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>
writetoamrutha is offline   Reply With Quote
Old 11-21-2010, 12:02 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,102
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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 http://www.codingforums.com/showthread.php?t=2090 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
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
cells, dynamic table cell, javascript, table cells, tables

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:13 PM.


Advertisement
Log in to turn off these ads.