Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
load values in a table
Old 08-18-2008, 04:30 AM load values in a table
Junior Talker

Posts: 2
Name: Paolo
Trades: 0
I'm new with javascript. I'm trying to load some values in a table with the help of javascript. Here what I have so far, it is just a simple example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p>
<script type="text/javascript">
function ShowReg(op) {
document.getElementById('fiat').style.display='non e';
document.getElementById('volvo').style.display='no ne';
document.getElementById('ford').style.display='non e';

if (op == 1) {
document.getElementById('fiat').style.display="blo ck";
}
if (op == 2) {
document.getElementById('volvo').style.display="bl ock";
}
if (op == 3) {
document.getElementById('ford').style.display="blo ck";
}
}
</script>
</p>
<p><br>
</p>
<div id="fiat" style="display:none">
price <input type="text" id="price1" value="1000">
color <input type="text" id="color1" value="blue">
</div>
<div id="volvo" style="display:none">
price <input type="text" id="price2" value="2000">
color <input type="text" id="color2" value="white">
</div>
<div id="ford" style="display:none">
price <input type="text" id="price3" value="3000">
color <input type="text" id="color3" value="red">
</div>


<table width="498" border="1">
<tr bordercolor="#000000">
<td width="158"><select name="select" id="select" onchange="ShowReg(this.selectedIndex)">
<option value='0'>select type </option>
<option value="1">fiat </option>
<option value="2">volvo </option>
<option value="3">ford </option>
</select></td>
<td width="134">cell 1</td>
<td width="184">cell 2</td>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>

I would like that the price is loaded in cell1 and color in cell2 and not anywhere on the page.

Can you give me some hints and tips?
paldo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-18-2008, 04:49 PM Re: load values in a table
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
give the cell an id and use innerHTML
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-19-2008, 07:28 AM Re: load values in a table
Junior Talker

Posts: 2
Name: Paolo
Trades: 0
Sounds to be a good idea. I already googled a bid in order to find some examples with innerHTML and tables, but couldn't find any. Will continue my search. Thanks.
paldo is offline
Reply With Quote
View Public Profile
 
Old 08-19-2008, 03:43 PM Re: load values in a table
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
document.getElementById("cell_id_attribute").inner HTML = "Some text in this cell";
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to load values in a table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41757 seconds with 12 queries