473,406 Members | 2,710 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.

Printin values in the text boxes

Dheeraj Joshi
1,123 Expert 1GB
Hi i have a problem.

I have 7 text boxex with different id's. I want to run a script via AJAX and i want to populate the result of the script in to these text boxes.

The code is

Expand|Select|Wrap|Line Numbers
  1. function show(id)
  2. {
  3.     id1=id;
  4.  
  5.     xmlhttp=GetXmlHttpObject();
  6.  
  7.     if (xmlhttp==null)
  8.     {
  9.         alert ("Your browser does not support AJAX!");
  10.         return;
  11.     }
  12.  
  13.     var url="index.php";
  14.  
  15.     xmlhttp.onreadystatechange=stateChanged;
  16.     xmlhttp.open("GET",url,true);
  17.     xmlhttp.send(null);
  18.  
  19. }
  20.  
  21. function GetXmlHttpObject()
  22. {
  23.     if (window.XMLHttpRequest)
  24.     {
  25.         // code for IE7+, Firefox, Chrome, Opera, Safari
  26.         return new XMLHttpRequest();
  27.     }
  28.     if (window.ActiveXObject)
  29.     {
  30.         // code for IE6, IE5
  31.         return new ActiveXObject("Microsoft.XMLHTTP");
  32.     }
  33.     return null;
  34. }
  35. function stateChanged()
  36. {
  37.  
  38.     if (xmlhttp.readyState==4 )
  39.     {
  40.         if(xmlhttp.status==200)
  41.         {
  42.             form.elements[id1].value=xmlhttp.responseText;
  43.         }
  44.         else
  45.         {
  46.             alert("Danger");
  47.         }
  48.     }
  49. }
  50.  
  51.  
  52.  
  53.  
This script basically call a php script and i displays the value in to text boxes.

When i run this script it displays the value in the last text box only. All other text boxes are empty.

Can any one assist me in this problem?

Regards
Dheeraj
Aug 12 '09 #1
12 1867
Dheeraj Joshi
1,123 Expert 1GB
Updation.

function takes a argument id, which is basically text box id. I am reading it from a xml file and calling it.

code is:

Expand|Select|Wrap|Line Numbers
  1. function ajaxcall()
  2. {
  3.     var xmlDoc = callXML();
  4.     var length = xmlDoc.getElementsByTagName("pname").length;
  5.  
  6.  
  7.     for(var i=0;i<length;i++)
  8.  
  9.     {
  10.  
  11.         var id=xmlDoc.getElementsByTagName("pname")[i].getAttribute("id");
  12.         alert(id);
  13.         show(id);
  14.  
  15.     }
  16.  
  17. }
  18.  
so. When i place that alert intact after clicking ok for alert message it disalplays value in text box. if i remove it it will dislay the value in last text box.

Regards
Dheeraj
Aug 12 '09 #2
Dormilich
8,658 Expert Mod 8TB
just a question, are your IDs unique?
Aug 12 '09 #3
Dheeraj Joshi
1,123 Expert 1GB
No they are not unique..
Aug 12 '09 #4
Dormilich
8,658 Expert Mod 8TB
that’s why you have the problem. Ids MUST be unique.
Aug 12 '09 #5
Dheeraj Joshi
1,123 Expert 1GB
Sorry dormilich.. they are unique.....
Aug 12 '09 #6
Dormilich
8,658 Expert Mod 8TB
do you have a page, where I can have a look at the whole thing?
Aug 12 '09 #7
Dheeraj Joshi
1,123 Expert 1GB
Sorry... I cant give the link.

It is working fine in IE but not in FF.. Why this dependency...?

Is there any other way to takle it?
Aug 12 '09 #8
Dormilich
8,658 Expert Mod 8TB
@dheerajjoshim
check the Error Console and the script with FireBug (Firefox debugger add-on) (that’s what I’d have made otherwise)
Aug 12 '09 #9
dlite922
1,584 Expert 1GB
FF is right, IE is wrong (just as Doc)

Please make sure your code validates here:
http://validator.w3.org/#validate_by_input

Dan
Aug 12 '09 #10
Dheeraj Joshi
1,123 Expert 1GB
FF right IE wrong? In what sense?
Aug 12 '09 #11
Dormilich
8,658 Expert Mod 8TB
@dheerajjoshim
in the standards sense (which is pretty much everything when it comes to web development)
Aug 12 '09 #12
dlite922
1,584 Expert 1GB
@dheerajjoshim
I should have elaborated a little more:

If FF is not displaying something right, but IE is = your code is wrong (not up to standard)
If IE is not, but FF is = your code maybe right but needs a IE hack/workaround.


Dan
Aug 12 '09 #13

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

Similar topics

2
by: Tom Fitzgibbon | last post by:
Stupid question: How do I loop through many text boxes on a page and get values for each box and put into an array? For example document.CreateEvent.test1.value will not take an array value...
7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
1
by: Eskil | last post by:
Hi I have a form that supplies my query with information on two different variables. The form uses a lookup to display a list of 5 different customer types and 5 different types of...
3
by: ChadDiesel | last post by:
I'm new to Access and need some advice. I am trying to setup a database to print labels and reports for our shipments. I have set up a table with fields such as I have taken a snapshot of what...
1
by: ChadDiesel | last post by:
I'm new to access and need some help. I have a form with a shipment destination at the top. I then have a subform that I enter boxes for that shipment. I have several shipments going at a...
1
by: Intrepid_Yellow | last post by:
Hi, I have the following code that runs my report generator. The user selects a table from a combo box, then whatever fields they want from a list box. (This part all works and the report runs...
4
by: David Plotts | last post by:
I'm a beginner with VB.net, only had one class in college on it. I can't seem to remember how to add text boxes up. I want to add the values in text boxes together, and put the value into a...
5
by: kosta.triantafillou | last post by:
Hi all, I have a form that contains a lot of values. On this form there are also alot of popups that can be brought up. One of them does the following: Takes 2 values (x and y), concatenates...
1
by: mfaisalwarraich | last post by:
Hi Experts Around the World. Well im new to this paradise (Access). i have no experties in Access but i can still work with my mind :). i wish to request you people as under: I made a table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.