I need a way of updating a HTML list through javascript.
I was thinking nesting the list inside of a form then changing the form.display.value but not having any luck.
Update a list through javascript
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Update a list through javascript
Updating it with information from the client or server?
Fighting for peace is declaring war on war. If you want peace be peaceful.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Update a list through javascript
client. No refresh. Dynamically
Re: Update a list through javascript
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>YW!</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready( function()
{
$('textarea[name="input"]').keyup( function()
{
// clear list
$('ol').html('');
// repopulate
var lines = $(this).val().split('\n');
for( var i in lines )
{
$('ol').append('<li>' + lines[i] + '</li>');
}
});
});
</script>
</head>
<body>
<ol>
<li>Line 1</li>
<li>Line 2</li>
</ol>
<textarea name="input">Line 1
Line 2</textarea>
</body>
</html>Fighting for peace is declaring war on war. If you want peace be peaceful.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Update a list through javascript
THANKS you rock, i was able to pull out what I need.
Re: Update a list through javascript
jQuery saves the day again!
Need i say more? :p
Need i say more? :p
New Site Coming Soon! Stay tuned 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Update a list through javascript
haha yes I will give you that one 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Update a list through javascript
once again, thanks Chris. This helped more than you know.