• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Accessing indexed properties in Javascript

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is basically a JavaScript question. I just have basic knowledge of Javascript. I have dynamically generated rows of input elements on my page which create indexed elements in the HTML. One of the example of an element is as follows:

<input type="text" name="escrowItems[0].disbAmount" value="0.0">

I am unable to access this element through javascript. The following doesn't work in a javascript function:

document.forms[0].escrowItems[0].disbAmount.value='';

Is it possible to handle it through Javascript? If yes, how?


Thanks!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any time you have a dot or square brackets in an html element name, you have to use a different syntax to access it. Try this format:

document.forms[0].item('escrowItems[0].disbAmount').value
 
Charanjit Sidhu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merrill. It works fine!

When I had this problem, I tried to search some JS tutorials and books but could not find the solution.

Can you suggest some good tutorial and reference for JavaScript?

Thanks again!!!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best online reference for javaScript that I know of is Microsoft MSDN. Once the page opens, look at the left frame and select Web Development-->HTML and CSS-->HTML and DHTML Reference. One word of warning: This reference is obviously geared toward Microsoft Internet Explorer, and some of the information given does not apply to javaScript on other browsers.

If you're going to be serious about developing dynamic web pages and writing javaScript, it's worth it to invest in a book, rather than relying on whatever tutorials you can find on the internet. O'Riely's JavaScript The Definitive Guide by David Flanagan has been an indispensable resource for me.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello I got a similar question in case I want all the elements escrowItems[].disbAmount in an array, how do I access it in javaScript? I have been searching for this answer since long, please help.

 
Quick! Before anybody notices! Cover it up with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!