View Full Version : document.formname.fieldname.value not returning value

08-04-2006, 08:40 AM
Hello Everyone,
I have a page(Page A) which has user profile details like username, password etc , all Labels. Each label has a link called "Edit". When user clicks on Edit, the label changes to a textbox so that the user can modify his details. For this iam using AJAX. To change the label to a textbox, im using another page(Page B) which takes the request from Page A using AJAX, and sends the textbox's <input> tag in the response to Page A. After this im placing the response in PageA using innerHTML. Thats fine. Now i need to perform validations when the user submits the page. For this im tryin to use document.formname.fieldname.value in the javascript to get that value after editing, so that i can check that value for validations. Now the problem is, after Edit is clicked the document.formname.fieldname.value returns undefined, eventhough value is present in the textbox. I need to know the reason for that. I have tried using getElementById(), and i was successful in retrieving the value. But thats not the concern. I need to use document.formname.fieldname.value to get that value. Plz help. Thanks in advance.

08-04-2006, 10:11 AM
how could we know why? Show us the code.

I need to use document.formname.fieldname.value to get that value.

Really? How's that? What is the importance of how you get a value? If the code works, it's ok.

08-04-2006, 01:39 PM
like KOR said if getElementById() works then use that.

08-04-2006, 02:38 PM
The only thing I can think of (being that we can't see the code, so I may be missing the problem) is that when you put the item back onto the page, you are not attaching it to the form. You may need to appendChild or replaceChild to have the DOM register that the element is attached to the form.

Otherwise I'd go with what the others suggested; if getElementById works, just use that instead.

08-04-2006, 09:51 PM
The code ... the code... We need the code ( or the link to the test page on server, or an attachment)