Click to See Complete Forum and Search --> : dinamic write in page


vinsa
04-07-2003, 11:45 AM
Hi,
first sorry for my english.
I need from javascript. This is my webpage.
I want, when I click the button "Show In Table text 2"
the script to show "text two" in my table and when I
click the button "Show In Table text 3" to show in table
"text three". Is this possible? I try to do it, but it not
work. Where is my error?

<HTML>
<HEAD>
<title>webpage</title>
<META content="text/html; charset=windows-1251"
http-equiv=Content-Type>


<SCRIPT language=javascript type="text/javascript">

dayInfo = new Array
dayInfo[1] = "text one"
dayInfo[2] = "text two"
dayInfo[3] = "text three"
dayInfo[4] = "text 4"

function ShowInTable(thisDay) {
document.tbl.place.value =
dayInfo[thisDay]
}

</script>

</HEAD>

<BODY>

<center>
MY TABLE <br>
<TABLE name=tbl border=2 cellPadding=2 cellSpacing=2>
<TBODY>
<TR>
<TD width="220" name=place height=40> </td>
</tr>
</tbody>
</table>
<br>
<Button OnClick="ShowInTable(2)">Show In Table text 2</button>
<Button OnClick="ShowInTable(3)">Show In Table text 3</button>
</center>

</BODY>
</HTML>

pyro
04-07-2003, 12:12 PM
Something like this should work better for you:

<html>
<head>
<title>webpage</title>
<meta content="text/html; charset=windows-1251" http-equiv=Content-Type>

<script language="javascript" type="text/javascript">

dayInfo = new Array
dayInfo[1] = "text one"
dayInfo[2] = "text two"
dayInfo[3] = "text three"
dayInfo[4] = "text 4"

function ShowInTable(thisDay)
{
document.getElementById("place").innerHTML = dayInfo[thisDay];
}

</script>

</head>

<body>

<center>
MY TABLE <br>
<table name=tbl border=2 cellPadding=2 cellSpacing=2>
<tbody>
<tr>
<td width="220" id="place" height=40></td>
</tr>
</tbody>
</table>
<br>
<Button OnClick="ShowInTable(2)">Show In Table text 2</button>
<Button OnClick="ShowInTable(3)">Show In Table text 3</button>
</center>

</body>
</html>

vinsa
04-08-2003, 04:36 AM
Pyro you are great! Thank you!