• 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

Edit nested input element value attribute

 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I'm cloning the DIV node, modifying some element and appending it to the other node. Its basically adding more INPUT fields as per user demands..

This is what I want to do



The HTML code for 'root', from where I'm getting fields:



HTML code for 'insert' field.


Any Inputs ?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Helps to say what browser you are having issues with.

Eric
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no issues with any browser, I just need a method which will return a reference to the input element which is deeply nested in DIV tag, I can iterate over each child nodes, but I don't wanna those loops..

Is there any way, so that I can directly get the INPUT tag/element with name "manufacturerName" ?

The hierarchy is like this, (If my DOM concepts are good enough)

 
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
Well you can try to use:

getElementsByTagName("input")

Eric
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I used "getElementsByTagName("input") ", and the resulted code as follow:



The alert prints [object], but when I used any property for that object , like 'name' or 'value', its prints undefined..




And one more doubt, the clone elements has two "input" tags, one is "<input type="button" ... />" and second is "<input type="text" .... />", How do I know which one is extracted by method ?
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Obviously you will get an undefined element. The getElementsByTagName will return an array of input objects. Try to iterate over the array using for loop (the max length will be inputElement.length). Then you can print the individual elements by using inputElement[counter].value or inputElement[i].name.
And to differentiate between a text box and a button use the type property of the inputElement[counter] object.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aditya Keyal wrote: The getElementsByTagName will return an array of input objects.



Thanks !! , will get back here, If need further help..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic