JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old July 22nd, 2004, 06:34 AM
tonycava tonycava is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 tonycava User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 22nd, 2004, 06:37 AM
tonycava tonycava is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 tonycava User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
alert(elements[i].value); returns undefined

Sorry forgot to add that

alert(elements[i].value); is returning undefined

Reply With Quote
  #3  
Old July 22nd, 2004, 07:23 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #4  
Old July 22nd, 2004, 07:56 AM
tonycava tonycava is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 tonycava User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > How does document.getElementsByTagName work


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway