Forum start - Register
Name Password Forgot your password?

Forum start > web > development > Dynamically Updating Lists
Author
Thread
JDOG
Member


 

Location: 
Registered: 8/7/2006    Warnings: 0
Dynamically Updating Lists
Alright guys, I have a problem with a webpage I'm trying to create. I'm trying to update an unordered list dynamically. Essentially, there are menu items on the left hand side of the screen and when one is clicked, it is added to the list on the right hand side of the screen. This, I got no problem. The problem comes in when I try to delete the item on the right hand side of the screen. I want to be able to click the list item and have it delete from the list. I can't use a selection box...even though that would me so much easier. Here is some code, let me know if there are any solutions

<script type="text/javascript">
var count = 0;
function listadd()
{
++count;
var name = "item" + listcount;
document.getElementById("test1" ).innerHTML += "<li id="name" onclick="deleteitem(count)">' + name + '</li>'";
}

function deleteitem(a)
{
var name = "item" + a;
document.getElementById("name" ).style.visibility = 'hidden';
}
</script>


<input type="button" onclick="listtest()" value="My List" />
<ul id="test1">
</ul>

If there are any other easier solutions to this let me know. I have messed around with any trick that I have been able to find on the web. For the function deleteitem I had the most desirable results using the code up above but I have also tried messing with document.getElementById(name).innerHTML -=; now this leaves the bullet point and a NaN result. Hopefully this makes sense!
__________________
JDW
jdog44@gmail.com
10/4/2011 14:11 Link - Ip: Logged - Quote:
 
QuickView: Dynamically Updating Lists - JDOG 10/4/2011 14:11
 where do you have the rest of the code (i.e. is there a page... - tr 10/4/2011 16:13
 It's for a web programming class and of course it's a larger... - JDOG 10/4/2011 16:58
 i like the way i can credit the order by clicking the empty ... - tr 10/5/2011 09:23
 Hey now, stop ripping on my rushed piece of art lol. Well, b... - JDOG 10/5/2011 13:24
 
Forum start > web > development > Dynamically Updating Lists

Quick reply
You need to login before you can post.


Powered by ASPBB v0.5.2
© 2004-2006 ASPBB Developers team