...

View Full Version : Ajax-out of 3 forms, only last form element update



vsstephen
01-07-2009, 04:25 PM
I HAVE A 2 FORMS IN ONE PAGE. EACH FORM HAVING A SELECT ELEMENT NAME COL2, AM USING A FUNCATION CALLED getagentids() WHICH RETREIVE A DATA FROM MYSQL THROUGH PHP AND FILL THE SELECT ELEMENT. I WANT TO CALL THE FUNCTION AJAX CONTAINING FUNCTION getagentids() EVERY TIME WHEN THE PAGE LOAD OR WHEN ON CHANGE EVENT IN THE SAME COL2 SELECT ELEMENT. WHAT HAPPEN WAS FORM2 THAT IS "selectForm2" COL2 ONLY UPDATE. IF I ADD ONE MORE FORM, THE LAST FORM ONLY GETS UPDATED. OUT OF 2 FORMS THE SAME FUNCTION UPDATE ONLY ONE FORM SELECT ELEMENT. PLS GIVE ME SOME TIPS TO FIX THIS PROBLEM



<FORM NAME="selectForm1">
<SELECT NAME=COL2 style="WIDTH: 105px; BACKGROUND-COLOR: aqua" onchange="getagentids(this.form,'COL2');">
<OPTION selected VALUE="SELECT">SELECT</OPTION>
<OPTION VALUE="START" style="BACKGROUND-COLOR: lightgreen">START</OPTION>
</SELECT>
</FORM>
<FORM NAME="selectForm2">
<SELECT NAME=COL2 style="WIDTH: 105px; BACKGROUND-COLOR: aqua" onchange="getagentids(this.form,'COL2');">
<OPTION selected VALUE="SELECT">SELECT</OPTION>
<OPTION VALUE="START" style="BACKGROUND-COLOR: lightgreen">START</OPTION>
</SELECT>
</FORM>




function getagentids(inform,cname)
{

resetteamstatus();
formname = inform;
colname = cname;

var idValue = 'load';
formname.COL2.options.length =1;
var myRandom=parseInt(Math.random()*99999999); // cache buster
http.open("GET", urlxtp + escape(idValue) + "&rand=" + myRandom, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);

}

A1ien51
01-08-2009, 04:50 PM
Loose the caps, makes your post unreadble.

You code is not Object Oriented. So if you call it two times in a row when the first post is active you write over all of your previous global variables.

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum