Skip to main content
Participant
March 15, 2007
Question

Unable to read value of Text Field : Any help?

  • March 15, 2007
  • 2 replies
  • 449 views
I've following DOM structure:
body
form
div1
div2
textfield
button
div3
button

etc.


For some reason, I am unable to read the value of the textfield. What I am doing is...on div2 I've a button, onclick this div2 is hidden & div3 comes on the front. But, on trying to read this value of textfield...(where user is supposed to enter value), I am trying this:
----------------------------------------------------------------------------------------------------------------
var divElements=document.getElementsByTagName('div');
alert(divElements[1].getElementsByTagName("input")[1].value);
----------------------------------------------------------------------------------------------------------------
Alert returns ampty alert. :(

What am I doing wrong?

Regards
Webcoder
This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

webcoderAuthor
Participant
March 21, 2007
Hi envision3d,

Thanks for your response. I am now able to capture the values. :)
Now...interestingly I have landed in to a different problem.

Basically, I need to put a javascript on the head part of the document. So, what I have done is:

var theHeadNode=curDOM.getElementsByTagName('head');
var rtnScript="<script content...>";
theHeadNode[0].innerHTML+=rtnScript;

Interestingly...if I keep my cursor outside the DOM (you will get clarity by looking at the attached screenshot), it throws an error. How do I prevent this? The line number showed in the error has following code:

theHeadNode[0].innerHTML+=rtnScript;

Can you please advise on this?

Thanks in advance.
Regards
Webcoder

PS: I have uploaded a snapshot at: http://www.innindia.com/extensions/images/dw_error.JPG
Inspiring
March 15, 2007
Try something similar to:

var myDivs = dw.getDocumentDOM().getElementsByTagName("div");
paramObj.div__tag = myDivs[0];

alert(myDivs[0]);