 |
| Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 12th, 2006, 01:33 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Drop-down problem in Ajax
Hi,
I am developing an application in Asp.net in which I am using Ajax.
I have two drop-down in my page(Country and State)and one text box(City).State values get populate on te basis of Country seleted.I am able to do this thing in AJax it is displaying properly.But I am facing problem If I want to Edit any City.When page gets load I am retriving the Country and State stored in the database.I am populating Country throgh Code-behind.First time when page gets upload I retrive the values of State through Code-behind.After that I am populating the values of State throgh Ajax method.On GUI level It is working properly Idislplay right states).If I will not change the country but change only state then I am able to save data.But if I change the country and State and click save button it will change the country values perfectly but doesn't take the new value of State seleted.It take the values of State when the page get uploaded first time.
I am not able to understad why is it behaving so.Is it happening so boz page is not refeshing.
Regards,
Deepti
__________________
Regards,
Deepti
|
|

June 28th, 2006, 10:48 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Hi Dipti,
Though I don't have anser to your que. but I would like to know one thing...just look here:
I hope you will get when this function should callled ...
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("Tasks1").innerHTML=xmlHtt p.responseText
}
}
Now the thing is Tasks1 is combo box and hence innerHTML won't work, so how should i change it.. i tried .add but that also is not working...
If possible can you send your coding in AJAX in javascript for this event.
Thanks...
Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
|
|

July 10th, 2006, 02:00 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Im having the same problem :)
Have u found out to solve the problem?
|
|

July 31st, 2006, 10:48 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
yes i ded....do u want the soluction pls mail me if so..
Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
|
|

July 31st, 2006, 06:30 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi!
I'm still interested. I didn t had the time to solve that one. I've only disabled the eventValidation or something like that, but it lowers the security of the website. I tried several things, but they all need some time to be spent onm which i didnt had.
What have u done?
Regards,
Chris.
|
|

November 1st, 2006, 05:46 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
On selection of poject i m showing tasks in another dropdown..if only one task it will be selected by default, further on selection of task i m showing task description, so if only 1 task description has to be auto fill...
Okay..here is the code..
--------------------------------------
Source drop down:
<select name="ProList<%=i%>" onchange="showTask(this.value,<%=i%>)">
<option value="0">-------- Select Project --------</option>
</select>
-----------------------------------------
Some Javascripts
var xmlHttp;
var id;
function GetXmlHttpObject(handler)
{
var objXmlHttp=null
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
}
try
{
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler
return objXmlHttp
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled")
return
}
}
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler
return objXmlHttp
}
}
function showTask(str,eid)
{
var url="GetTask.asp?sid=" + Math.random() + "&q=" + str + "&M=T";
xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
id = eid;
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var resp;
resp = xmlHttp.responseText;
var ele = resp.split("!");
// -- Clear all old values of task drop down.
while(document.getElementById("Task"+id).options.l ength > 1)
document.getElementById("Task"+id).options.remove( document.getElementById("Task"+id).options.length-1);
// -- Add new values
for (var i = 0; i < ele.length-1; i++)
{
newOpt = document.createElement("OPTION");
document.getElementById("Task"+id).options.add(new Opt);
newOpt.value = ele[i];
newOpt.innerText = ele[i];
}
//---If only one task then
if (i == 1)
{
document.getElementById("Task"+id).selectedIndex = 1; // Select it
ShowDes(document.getElementById("Task"+id).value,d ocument.getElementById("Prolist"+id).value,id); // Call to show description
}
else //Else
{
document.getElementById("Des"+id).innerHTML = "";
}
}
}
--------------------------- gettask.asp
if Request.QueryString("q") <> "" and Request.QueryString("M") = "T" Then
subRs.open "Select Task from TimeEstMaster where ProID = '" & Request.QueryString("q") & "' and status = '0' and descn <> '' order by Tdate",objConn
if not subRs.EOF then
subRs.Movefirst
do while not subRs.EOF
response.write subRs(0) & "!"
subRs.Movenext
loop
end if
subRs.close
End if
Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
|
|

July 27th, 2007, 08:34 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi
while you are calling code behind aspx page change the method to post and check it.
|
|
 |