Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-19-2009, 04:40 AM   PM User | #1
javaguy1007
New Coder

 
Join Date: Mar 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
javaguy1007 is an unknown quantity at this point
process elements returned getElementsByName

Hi

I am new to AJAX. I am calling a Ajax function from jsp and I need to process elements returned by document.getElementsByName(),

getElementsByName returns 4 elements.

I did some thing like this , but it is not working please help me

function myfunction(id)
{

if(document.getElementsByName("myname").value!="")
{
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{
alert("Browser does not support HTTP Request");
return
}

var Id = document.getElementsByName("myname").value;

for (var i = 0, i<=4; i++) {
var url="myjsp.jsp"
url=url+"?Id="+Id

xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

}

}

Please help me
Thanks
[/FONT]
javaguy1007 is offline   Reply With Quote
Old 03-19-2009, 07:03 AM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
shouldn't you loop right away? You're creating elements, right? And you want to get them by name, so you gotta name them.


what's the value of id in myfunction(id)
I didn't see you use it anywhere. You're sending an empty var.

Later on down there, you're creating Id and giving it a value but I didn't see any value assigned other than getobject. Can you explain how it's supposed to work. I'm learning and I've not used php nor ajax methods yet, but i'd love to learn.

I wish I had a way to do php. Does anyone know if there's a way to have an old laptop work as a server so i can practice php?
TinyScript is offline   Reply With Quote
Old 03-20-2009, 12:54 AM   PM User | #3
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
You are using the same variable so you are overwriting the last call.

Use a JavaScript library and make your life easier with Ajax calls.

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Users who have thanked A1ien51 for this post:
javaguy1007 (03-24-2009)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:33 PM.


Advertisement
Log in to turn off these ads.