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 12-27-2005, 07:47 PM   PM User | #1
Javanic99
New to the CF scene

 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Javanic99 is an unknown quantity at this point
Calling a page element from a string.

Hi,

I haven't done any Javascript for a few years now but I'm sure I have found a way around this before.

I have a table containing values. One of the TDs in each row has an input box so that users can input a value. When this changes I want to recalculate some of the other TDs in that row.

I can get the row number from string manipulation of the input box source element ID. I then want to write back to the table using a row and column id name built from this ID.

how do I use my new string so that I can assign a value to the page object of the same name?

Thanks,

Nick
Javanic99 is offline   Reply With Quote
Old 12-28-2005, 10:21 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Something like this?
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
meta http-equiv="Content-Style-Type" content="text/css">
<
meta http-equiv="Content-Script-Type" content="text/javascript">
<
script type="text/javascript">
function 
calculate(inp){
var 
cells inp.parentNode.parentNode.getElementsByTagName('td');
cells[4].firstChild.data Number(inp.value)+Number(cells[2].firstChild.data)
}
</script>
</head>
<body>
<table width="250" border="0" cellspacing="2" cellpadding="2">
<tr> 
<td> <input name="textfield" type="text" size="5" onkeyup="calculate(this)"> </td>
<td>+</td>
<td>10</td>
<td>=</td>
<td>10</td>
</tr>
<tr> 
<td> <input name="textfield" type="text" size="5" onkeyup="calculate(this)"> </td>
<td>+</td>
<td>20</td>
<td>=</td>
<td>20</td>
</tr>
<tr> 
<td> <input name="textfield" type="text" size="5" onkeyup="calculate(this)"> </td>
<td>+</td>
<td>30</td>
<td>=</td>
<td>30</td>
</tr>
</table>

</body>
</html> 
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

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:45 PM.


Advertisement
Log in to turn off these ads.