|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
How does document.getElementsByTagName work
I need to pick up the following element from a form
<input type="text" name="new_limit" size=10> In my java script I have the following code: <script language="javascript"> function submitAll() { var elements = document.getElementsByTagName("newlimit"); for (var i = 0; i < document.forms.length - 1; i++) { var input = document.createElement("input"); input.type = "hidden"; alert(elements[i].value); } } </script> I have put the element within the <newlimit> tags <newlimit><input type="text" name="new_limit" size=10></newlimit> Am I using the wrong havascript function and that document.getElementsByTagName should not be used on a form. Thanks for any help Tony |
|
#2
|
|||
|
|||
|
alert(elements[i].value); returns undefined
Sorry forgot to add that
alert(elements[i].value); is returning undefined |
|
#3
|
||||
|
||||
|
Wrap your alert in "if(elements[i].value){ }" to get rid of the error. Of course, you've still got something weird going on because i represents the number of forms and not the number of elements in a given form. Seems kind of a weird way of doing things. It strikes me that it's possible that getElementsByTagName() isn't working because it's expecting valid DOM elements, of which newlimit is not one.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#4
|
|||
|
|||
|
Thanks, so I am going the wrong way about trying to solve this problem.
Do you know what javascript function I can use to pick up the form elements new_limit and borg_num In my code it is like this within a loop <form name="limits" method=POST action="global"> <input type="text" name="new_limit" size=10> <input type="hidden" name="borg_num" value="<%= rs.getString("borg_num") %>"> <input type="submit" value="Amend Limit"> </form> how do I say in javascript pick up all text identified by new_limit in the form limits. The problem is that thery want to keep the amend a single limit button and as well as have a new amend all limit button. Thanks for any help Tony Thansks for any help, getting slightly desparte |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > How does document.getElementsByTagName work |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|