This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Using text fields to update a selection list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Using text fields to update a selection list" Watch "Using text fields to update a selection list" New topic
Author

Using text fields to update a selection list

Maia Miller
Greenhorn

Joined: Mar 22, 2010
Posts: 3
Hello everyone, I am new here. And I'm a beginner with JavaScript, I'm taking my first class about it and we are rushing through it. It's all really confusing to me and I could use a little bit of help. Not asking anyone to do the assignment for me or anything, just any pointer in the right direction would be extremely helpful. The assignment is to create a form for a baseball team that allows the coach to create a list of players by filling out the contact fields and having that information transfer to a selection list. Now, the past couple of chapters have been way over my head and I've been on the verge of tears trying to figure it all out. So, any help would be greatly appreciated. I tried searching the forum for something similar already posted, but didn't find anything. If there is something, please point me to it and this thread can be closed.

(Edit* - code below)

But, it's far from complete and it's probably all completely wrong and mangled. Sorry. I'm using code from the chapter and trying to make it work for the assignment, but for now all I want is the Add Player button to work, once that works, I will try and figure out the rest. So, if you could just look over the add contact part and let me know what could be throwing me off, I'd appreciate that so much. Thank you for reading all of this.

Also, sorry again for how horrible the code will probably look. Like I said, I'm in way over my head here >_<
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Maia Miller wrote:(you can view source from there I figured..)

Making people work hard to help you is less likely to get you the help you need.

Rather, pare the problem down to the smallest example that demonstrates the issue and post it. People here will be glad to help you, but you must put your effort into making it as easy to help you as you can.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Maia Miller
Greenhorn

Joined: Mar 22, 2010
Posts: 3
Sorry, I read that in the FAQ, but I figured it'd be easier since my code is so long. I apologize. I don't see how to edit my original, so I'll post here instead. (Edit: found the edit button, ha, but I don't know which part of the code to single out and post since it seems as though they are all linked. But, if you'd like me to shorten it and only post a certain part, I'll do so. Sorry again, first time posting and completely out of my league with the JS stuff)

Here is the code that I have:


Sorry it's so long.. The HTML part is here:



And the link in the first post can show how it looks in the browser I guess. Sorry again, hope this helps.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I may have missed it, but what's the actual issue? See ItDoesntWorkIsUseless.

I like the picture of the frozen fountain.
Maia Miller
Greenhorn

Joined: Mar 22, 2010
Posts: 3
David Newton wrote:I may have missed it, but what's the actual issue? See ItDoesntWorkIsUseless.

I like the picture of the frozen fountain.


Glad you like the picture.

The problem was that I needed help figuring out why the Add Contact function or button wasn't working. But, I'm too stupid about it all to convey it using the proper protocol here. I can't really think of any other way to say exactly how it isn't working, because JavaScript is still just a bunch of garbled nonsense to me. It's my first ever class with any type of scripting or programming language. So, it's ok. I'll figure it out somehow. Thanks for at least replying.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

We're all happy (possibly giddy, even) to help, but we have to have a starting place.

The first thing that I see is that the first thing you do is loop over the existing contact list (I assume, I didn't see where it's defined) and promptly overwrite whatever is in there. If you're trying to figure out where the end of the list is, you'll want to do it *before* adding anything to the list (in other words, there should be a complete loop through the list first if you're going to do it like that).

You'll also run in to a problem where you delete a contact from the middle of the list: the count of contacts will no longer line up one-to-one with the map key you're using (in other words, the third object in the list might be contact #4, if you've deleted #1, 2, 3) and this might also cause a data integrity issue.
 
 
subject: Using text fields to update a selection list
 
Similar Threads
Head First Java by Bert Bates, Kathy Sierra
Trouble with GridLayout, BoxLayout .... any sort of layout!
Connection Pooling Help Needed
Split String to Array - why doesn't this work?
Following the Javaranch programming style guide....