File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Three newbie questions 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 "Three newbie questions" Watch "Three newbie questions" New topic
Author

Three newbie questions

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Three newbie questions
1.
a. var aField = myForm['aField'];
b. var aField = myForm.document.getElementById('aField')
what is the difference between the two ?

2. Does JS string have same function as aString.trim() in java ?

3. Where can I find some mature JS utility package, just like jar component in Java ?

Thanks for your help.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
1.
a. var aField = myForm['aField'];
b. var aField = myForm.document.getElementById('aField')
what is the difference between the two ?

getElementnById is a DOM method to find an element by its id. Ids have to be sigular so you can not have more than one element on the page with that id. The other references the form object for a name, names can be repeated on a page! IE is bad and allows for name to be seached by getElementById, but no other browsers allow that. So do not do it! Just a warning!

var myElem = document.forms["name or index number"].elements["name or index number"] is the full way to reference an element with the form object array and element array.

2. Does JS string have same function as aString.trim() in java ?
No, but you can add this to your funcitons and it adds the functionality to the string object:



3. Where can I find some mature JS utility package, just like jar component in Java ?
Guess you are asking for a library? Look for prototype.js (Google should be first result)

Eric
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Three newbie questions
 
Similar Threads
Connection reset by peer: socket write error
Java Developer, Entry Level Position, What would you expect?/
Can we serialize the Static variable
Distinct select giving a problem
missing name after . operator ?