Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-04-2010, 05:32 PM   PM User | #1
spriggo
New to the CF scene

 
Join Date: Aug 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
spriggo is an unknown quantity at this point
Post data not being sent

Hi,

I've created a couple of dropdown boxes. The user selects their option from the first box and this activates an ajax call to populate the second box.

If the form doesn't validate and the page and form is reloaded, it remembers my selections.

However, it doesn't recognise that I have made a selection and the post data for that drop down is empty, which leads me to be believe that the page is not posting the data from the ajax generated drop down list.

I've checked my code and this is sound.

Any help is much appreciated.

Here's the html:

Code:
<select name="hotel_name_1" onchange="getLocations('1', this.value)">
<option>Select Hotel</option>
<!--LIST OF OPTIONS-->
</select>

<span id="locations1">
<select name="hotel_selection_1">
<option></option>
</select>
</span>
And here's the javascript:

Code:
<script type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
}

function getLocations(selectid, hotelId)
{
   var strURL="_getLocations.php?id="+hotelId+"&section="+selectid;
   var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
      if (req.readyState == 4)
      {
	 // only if "OK"
	 if (req.status == 200)
         {
	    document.getElementById('locations'+selectid).innerHTML=req.responseText;
	 } else {
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);
	 }
       }
      }
   req.open("GET", strURL, true);
   req.send(null);
   }
}
</script>
spriggo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:44 AM.


Advertisement
Log in to turn off these ads.