Solved

passing multiple values using xmlhttp.send

Posted on 2010-08-21
4
2,374 Views
Last Modified: 2012-05-10
I am using the script below to pass values from a form to a php page.  The first xmlhttp.send always returns a value, the second one is always blank. I am trying to figure out how to send multiple values using xmlhttp.send
if(xmlhttp) { 
  	var txtname = document.getElementById("txtname");
	var number  = document.getElementById("number");
    xmlhttp.open("POST","testing.php",true); //calling testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("txtname=" + txtname.value); //Posting txtname to PHP File
	xmlhttp.send("number=" + number.value); //Posting number to PHP File
  }

Open in new window

0
Comment
Question by:brad0525
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33492405
what about :


xmlhttp.send("txtname=" + txtname.value + "&number=" + number.value);

or

xmlhttp.send("txtname=" + encodeURI(txtname.value) + "&number=" + encodeURI(number.value));

Open in new window

0
 

Author Closing Comment

by:brad0525
ID: 33492416
Thanks works perfect
0
 
LVL 1

Expert Comment

by:FractalPat
ID: 33492420
Have you tried something like this:

xmlHttp.send("txtname=txtname.value&number=number.value");
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33492421
You're welcome! Thanks for the points!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now