Jump to content

Ajax Div Not Posting Values


heminfotech

Recommended Posts

Hi Everyone

 

I have a critical Issue I am not able to find solution on this.

 

I have one registration for where on selecting countries the rest of details like street no & name zip state city etc is coming. so i am getting the data and replacing it through AJAX request.

 

I am not able to find the data when I post the same form it gives me error like this

 

[b]
This is the array I am getting[/b]

email => abc@abcd.com
amt => 49.98
password1 => hemal
cnfPass => hemal
paypal_id => hemal.jivani@gmail.com
que => hemal
ans => Hemal
day => 4
month => 6
artistname => Hemal
firstnm => ASDF
lastnm => ASDF
country => Austria
phone => 123456789
url => http://pidex.ca/
gender => M
gmail => 1


[b]This is the errors I am getting. I have already compared the names of the fields please don't give such an answer. It works in some of the pages and not in some. [/b]
Notice: Undefined index: street in D:\work\WQM\artistsignupstep3_a.php on line 20

Notice: Undefined index: city in D:\work\WQM\artistsignupstep3_a.php on line 21

Notice: Undefined index: state in D:\work\WQM\artistsignupstep3_a.php on line 23

Notice: Undefined index: otherstate in D:\work\WQM\artistsignupstep3_a.php on line 29

Notice: Undefined index: zip in D:\work\WQM\artistsignupstep3_a.php on line 32

Notice: Undefined index: newsletters in D:\work\WQM\artistsignupstep3_a.php on line 45

 

Is there anyone who can help me on this or may be have some solution on this.

 

Thanks for all your helps in advance

 

Regards

Hemal Jivani

Link to comment
Share on other sites

Hi

 

Please find all the things that you need

 

AJAX REQUEST

// JavaScript Document
function createRequest() {
	try {
		request = new XMLHttpRequest();
	} catch (trymicrosoft) {
	try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (othermicrosoft) {
	try {
		request = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (failed) {
		request = false;
	}
	}
	}
	return request; 
}

function getStates(val){
getStateReq = createRequest();
//alert(document.getElementById("arrid").value);
if(val==2)
 {
	 id = document.getElementById("country").value;
	 tag='country';
	 var url = "findstate.php?__=" + encodeURIComponent((new Date()).toString()) +"&cnt_id="+id+"&val="+val;

	getStateReq.open("GET", url, true);
	getStateReq.onreadystatechange = getStateRes;
	getStateReq.send(null);
 }
 else
 {
	if (val==0)
	{
		//alert(document.getElementById("country").value);
		id = document.getElementById("country").value;
		tag='country';
	}
	else
	{
		id = document.getElementById("country1").value;
		tag='country1';
	}

	var url = "findstate.php?__=" + encodeURIComponent((new Date()).toString()) +"&cnt_id="+id+"&val="+val;
	//alert(url);
	getStateReq.open("GET", url, true);
	getStateReq.onreadystatechange = getStateRes;
	getStateReq.send(null);
 }
}
function getStateRes(){
if (getStateReq.readyState == 4) {
//alert(getStateReq.status);
	if (getStateReq.status == 200) {
	var	resGetState=getStateReq.responseText.split("!@#$%%$#@!");
		if (resGetState[1]==1)
		{ 
			document.getElementById("addDetails1").innerHTML=resGetState[0];
		}
		else
		{
			document.getElementById("addDetails").innerHTML=resGetState[0];
		}
		//document.getElementById("addDetails").style="visibility:visible";
	}
}
}

 

 

 

REQUESTED PAGE CODE


<?
include_once 'functions.php';
include_once'config.php';

$cnt_id=$_REQUEST['cnt_id'];

$getCntNm=mysql_fetch_array(mysql_query("select * from countries where name='$cnt_id'"));

$rs=mysql_query("select * from states where Country=".$getCntNm['id']);

?>

<table width="100%">
<tr>
<td ><?
if($_REQUEST['val']==2)
{
	if(mysql_num_rows($rs)>0)
	{
	?>
	<select name="state" class="contentfont" id="state"  >
							<option value="-1" >                                                          </option>
								<?

										while ($staes = mysql_fetch_array($rs)) {
											echo "<option value=\"".$staes['Name']."\" ".(($staes['Name']==$_POST['state'])?"selected":"").">".$staes['Name']."			</option>";
										} ?>
</select>

	<?
	 }
	 else {
	  
	  ?>
		<input type="text" name="state" id="state" size="30"  />

	  <?
	}
}		
else
{
if(mysql_num_rows($rs)>0)
	{
	?>

	<table width="100%" height="143" cellpadding="0" cellspacing="0">
	  <tr>
		<td align="right" ><span class="style15"> *Street Name & Number: </span> </td>
		<td><input type="text" name="street" id="street" size="30" /></td>
	  </tr>
	  <tr>
		<td align="right" ><span class="style15">*Town or City : </span></td>
		<td><input type="text" name="city" id="city" size="30" /></td>
	  </tr>
	  <tr>
		<td align="right" ><span class="style15">*Province or State : </span></td>
		<td><select name="state" class="contentfont" id="state" >
							<option value="-1"> </option>
								<?

										while ($staes = mysql_fetch_array($rs)) {
											echo "<option value=\"".$staes['Name']."\" ".(($staes['Name']==$_POST['state'])?"selected":"").">".$staes['Name']."</option>";
										} ?>
							 </select></td>
	  </tr>
	  <tr>
            <td width="38%" align="right"><span class="style15">Other: </span></td>
            <td width="59%"><input name="otherstate" type="text" id="otherstate" size="28" /></td>
          </tr>
	  <tr>
		<td align="right" ><span class="style15">*Postal or Area Code : </span> </td>
		<td><input type="text" name="zip" id="zip" size="30" maxlength="6" /></td>
	  </tr>
</table>
	<?
	 }
	 else {
	  
	?>
		<table width="100%" height="143" cellpadding="0" cellspacing="0">
	  <tr>
		<td width="38%"  align="right" ><span class="style15">*Street Name & Number: </span> </td>
		<td width="59%"><input type="text" name="street" id="street" size="30" /></td>
	  </tr>
	  <tr>
		<td align="right" ><span class="style15">*Town or City : </span></td>
		<td><input type="text" name="city" id="city" size="30" /></td>
	  </tr>
	  <tr>
		<td align="right" ><span class="style15">*Province or State : </span> </td>
		<td><input type="text" name="state" id="state" size="30"  /></td>
	  </tr>
	  <tr>
                 <td  align="right"><span class="style15">Other: </span></td>
            <td ><input name="otherstate" type="text" id="otherstate" size="28" /></td>
              </tr>
	  <tr>
		<td align="right" ><span class="style15">*Postal or Area Code : </span></td>
		<td><input type="text" name="zip" id="zip" size="30" maxlength="6" /></td>
	  </tr>
</table>
	 <?
	 }
}		 
?>
</td>
</tr></table>

 

Thanks for all your support.

 

Hope this will help. If you need something else let me know

 

 

 

 

 

Regards

Hemal Jivani

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.