Update a list through javascript

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Update a list through javascript

Post by hallsofvallhalla »

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.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Update a list through javascript

Post by Chris »

Updating it with information from the client or server?
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Update a list through javascript

Post by hallsofvallhalla »

client. No refresh. Dynamically
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Update a list through javascript

Post by Chris »

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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Update a list through javascript

Post by hallsofvallhalla »

THANKS you rock, i was able to pull out what I need.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Update a list through javascript

Post by Torniquet »

jQuery saves the day again!

Need i say more? :p
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Update a list through javascript

Post by hallsofvallhalla »

haha yes I will give you that one ;)
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Update a list through javascript

Post by hallsofvallhalla »

once again, thanks Chris. This helped more than you know.
Post Reply

Return to “Advanced Help and Support”