• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing the DOM

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have HTML form with many checkboxes (with the same name) plus other HTML controls like buttons, etc. What I would like to do is walk the DOM, ie document.forms[0].elements, and get information from these various HTML controls. However, I need to determine what type of HTML control I'm currently processing so I can call the appropriate properties on them, ie the 'checked' property for a checkbox etc. Could somebody explain whats required to do this?

thanks in advance,

Susan
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basic idea:



I wrote the above without testing...

Eric
 
Susan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric,

thats what I was looking for!

If I can ask you another question, I have a table where the first column is a checkbox, and the other columns are just text labels. I was hoping that I would be able to determine the textual label associated to a selected checkbox - but these text labels arent in the document.forms[0].elements array.

One option I had was to store the textual labels as a comma separated string in a hidden property and then parse the label from this. However, the table could be very large (and I only display 10 rows at a time in the table) so this solution would require downloading all text labels for every page of the table displayed - which isnt a good solution.

Anyway, would you have any other ideas for this?


thanks again,

Susan
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like this:



Eric
 
Susan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
many thanks Eric!

Susan
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic