I am new to JavaScript and just learning the basics of it. I am doing a sample program and crated a javascript program to show some data in a html page inside div. but it is not dynamic. I have some values like name, addess, age and status of few staff and while log in with a user name showing the above details in html page. this is a simple program.
What i want to do is, i want to dynamically increase the size of the div or table where i can display details of use like address, age, status etc.. if some user has more details then i want to add that in the html page. how can i do it ??
in home.jsp i have the following code.
<table>
<div id="name1" width:400px;"></div>
<div id="address1" width:400px;"></div>
<div id="age1" width:400px;"></div>
<div id="status1" width:400px;"></div>
</table>
this is the function i use in home.js
function(json)
{
var content= $('#name1').replaceWith('<tr><td> Name: ' + json.name + '<tr><td>');
var content= $('#address1').replaceWith('<tr><td> Name: ' + json.address + '<tr><td>');
var content= $('#age1').replaceWith('<tr><td> Name: ' + json.age + '<tr><td>');
var content= $('#status1').replaceWith('<tr><td> Name: ' + json.status + '<tr><td>');
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…