473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Change two different elements with one ajax call

bugboy
160 100+
This ajax is called from an onclick in a form element. I want to use one call to change 2 different elements. Is there a way to change the contents of another element at the same time, not just list_id? I'm having a tough time getting my head around js. and have tried lots of different things with no luck :(

Thanks!

Expand|Select|Wrap|Line Numbers
  1. function save_edit_row(list, value)
  2.     { 
  3.     xmlHttp=GetXmlHttpObject()
  4.     if (xmlHttp==null)
  5.          {
  6.          alert ("Browser does not support HTTP Request")
  7.          return
  8.          }
  9.     var url="save_edit_row.php"
  10.     url=url+"?list="+list
  11.     url=url+"&row_num="+row_num
  12.     url=url+"&value="+value
  13.     url=url+"&rand="+Math.random()
  14.     xmlHttp.onreadystatechange=list_stateChange
  15.     xmlHttp.open("GET",url,true)
  16.     xmlHttp.send(null)
  17.     }
  18.  
  19.  
  20.  
  21.  
  22. function list_stateChange()
  23.     { 
  24.     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  25.          { 
  26.          document.getElementById('list_id').innerHTML=xmlHttp.responseText 
  27.          } 
  28.     }
  29.  
  30.  
  31.  
  32. function GetXmlHttpObject()
  33.     {
  34.     var xmlHttp=null;
  35.     try
  36.          {
  37.          // Firefox, Opera 8.0+, Safari
  38.          xmlHttp=new XMLHttpRequest();
  39.          }
  40.     catch (e)
  41.          {
  42.          //Internet Explorer
  43.          try
  44.               {
  45.               xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  46.               }
  47.          catch (e)
  48.              {
  49.              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  50.              }
  51.          }
  52.          return xmlHttp;
  53.     }
Nov 13 '08 #1
1 1442
acoder
16,027 Expert Mod 8TB
Yes, you can. Split the response text and set one to one element and the other to the second element, e.g. if you return "one|two", you can use .split("|") to get an array where arr[0] would contain "one" and arr[1] "two".
Nov 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
3
by: robert.oschler | last post by:
I have an AJAX driven page where I dynamically add rows to a known table on the page, based on the return document from the AJAX call, using DOM node methods (except for a small snippet of code,...
34
by: Luke | last post by:
Hi! I am new to PHP but I am a very experienced in Perl/CGI/templates. I work in medical informatics when we deal with very large data collection forms. Some of them have over 1000 elements!...
13
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone...
5
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the text in the url/location bar?...
14
by: adamjblakey | last post by:
Hi, I have a function here: var AdminResponse = ""; function parseResponse(){ var nText = AdminResponse.getElementsByTagName('optionText');
22
by: sheldonlg | last post by:
I am looking for a clean solution to a problem that I solved in, what I call, a "dirty" way. Here is what I want to do. I have a dropdown list. Clicking on an item in the dropdown list invokes...
2
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.