|
I have a web page where people can enter their name and address into text input fields.
Using JavaScript,
I want them to be able to click a button that will make their entered information appear in a designated table on the same page.
Can this be accomplished relatively easy?
Any suggestion would be greatly appreciated,
Thanks
|
|
|
Sure! A DHTML solution is what you need. You say you want to copy the values into a table. Will the table cells already exist? Or do you need to also write the table cells?
|
|
|
|
|
I had planned on having a table already created and positioned a little lower on the page.
Basicly I wanted to populate the cells of the table with the values from my input fields. Perhaps by using the "onclick" command.
|
|
|
You mean like this?
<script language=javascript>
function CopyValues()
{
var f = document.forms[0];
document.getElementById("colName").innerHTML = f.fullName.value;
document.getElementById("colAddress").innerHTML = f.address.value;
document.getElementById("colCity").innerHTML = f.city.value;
document.getElementById("colState").innerHTML = f.state.value;
}
</script>
<form>
Name<br>
<input type=text name=fullName><br>
Address<br>
<input type=text name=address><br>
City<br>
<input type=text name=city><br>
State<br>
<input type=text name=state><p>
<input type=button value="Copy Values" onclick=CopyValues()>
</form>
<table border=1 cellpadding=4>
<tr>
<th width=100>Name</th>
<th width=200>Address</th>
<th width=100>City</th>
<th width=50>State</th>
</tr>
<tr>
<td id=colName>Â </td>
<td id=colAddress>Â </td>
<td id=colCity>Â </td>
<td id=colState>Â </td>
</tr>
</table>
|
|
|
|
|
|
|
This worked perfectly.
Thanks for your help.
|
|
|