n33dl3 Posted April 8, 2007 Share Posted April 8, 2007 Hi there What is the right way to handle more then one $_GET Value? -- // Function handles the response from the PHP script. function handleResponse() { // If everything's okay: if(http.readyState == 4){ // Assign the returned value to the document object. document.getElementById('outcome').value = http.responseText; -- Now let's say I have two ID elements and the response text has two values, how can I send the first value to the first element id and the second to the second element id? Do I need to add something like"document.getElementById('aer_version').value = http.responseText;" I need to split somehow the response text Thanks a lot Regards RobH Quote Link to comment Share on other sites More sharing options...
tomfmason Posted April 8, 2007 Share Posted April 8, 2007 You could use xml or json and that would be much easier. However, you could simply use something to split the response, like a comma or whatever. Then you could split by the divider. I will give you an example. In this example I am going to assume that you are using a | to divide the responses. So lets say the response from your php file is. Joe Smith | Something about Joe Smith and here is how you could split the response with js. function handleResponse() { if (http.readyState == 4) { var response = http.responseText; //split the response by our separator var parts = response.split("|"); //write the first part of the split to your first div document.getElementById('div1').innerHTML = parts[0]; //write the second part of the split to your second div document.getElementById('div2').innerHTML = parts[1]; } } Now normally I would say to use xml or json but since you only have two responses coming back i would just do it that way. Hope that helps, Tom Quote Link to comment Share on other sites More sharing options...
n33dl3 Posted April 9, 2007 Author Share Posted April 9, 2007 Hi Tom, Thanks a lot that was exactly what I was searching for. What kind of tools are you using for debugging JavaScript? Best regards RobH Quote Link to comment Share on other sites More sharing options...
tomfmason Posted April 9, 2007 Share Posted April 9, 2007 I write most of my javascript in aptana. It has a built in js debugger. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.