I have a textbox for user input with a submit button. I would like for the user to be able to put in some input, and have the input appear in a list underneath the input box, maybe into a table using some kind of javascript function. To me this seems like a fairly simple concept but I can't find any tutorials that will show me how to do it, can anyone recommend any or tell me what the best, most attractive looking approach to this would be?
EDIT- Here's what I've tried:
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.getElementById("add").onClick = function() {
var text = document.getElementById("idea").value;
var li = "<li>" + text + </li>;
document.getElementById("list").appendChild(li);
}
</script>
<input type='text' id = 'idea' />
<input type='button' value = 'add to list' id = 'add'>
<ul id= 'list'>
<li> <b>Topics</b></li>
</ul>
</body>
</html>
I can give a quick run through of what you'll need. First, you'll want your basic text input with an ID:
And obviously a button to add to the list:
And a list to be adding to:
Now for the fun JS, see the play-by-play in the comments
here is a basic jquery implementation:
http://jsfiddle.net/MW8HS/
I think it work but not changing li style:
Below is the basic JavaScript code that will do the job.
HTML