473,414 Members | 1,609 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,414 software developers and data experts.

problem in using ajax function

hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand whats the prob.this is the code i m using:
[PHP]
<?
include("config.inc.php");
//error_reporting(0);


if(isset($_REQUEST['Submitstore2'])=="Delete")
{
$storeno=$_REQUEST['storeno'];
$sql_storedelete="delete from store_info where storeid='$storeno'";
mysql_query($sql_storedelete);

}
if(isset($_REQUEST['Submitstore'])=="Update")
{

$storeno=$_REQUEST['storeno'];
$storename=$_REQUEST['storename'];
$warehousename=$_REQUEST['warehousename'];
$storecontactno=$_REQUEST['contactno'];
$note=$_REQUEST['note'];
$storecontactperson=$_REQUEST['contactperson'];

if($storeno!="" && $storename!="" && $warehousename!="" && $storecontactno!="" && $note!="" && $storecontactperson!="")
{
$sql_storeupdate="UPDATE `store_info` SET `storename`='$storename', `warehouse`='$warehousename', `contactperson`='$storecontactperson', `contactno`='$storecontactno',`note`='$note' WHERE `storeid`='$storeno'";
//echo $sql_storeupdate;
mysql_query($sql_storeupdate);
$msg="updated";
}
else
{
$msg="error";
}
}

?>[/PHP][HTML]
<html>
<head><title>store Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="<?php echo $NF_config['css_file'];?>" rel="stylesheet" type="text/css">
<link href="_css/nf_style.css" rel="stylesheet" type="text/css">
<style type="text/css">
.style1 {font-size: 9}
</style>
<link href="../../_css/nf_style.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">[/HTML]
Expand|Select|Wrap|Line Numbers
  1.   function loadIndividual(form) {
  2.     var gifName=form.storeimageupload.value;
  3.     document.getElementById('hidimg').value=gifName;
  4.     //alert(gifName);
  5.     document.getElementById('storeimage').src=gifName;
  6.  
  7. }
  8. function backtomain()
  9. {
  10. window.location="http://localhost/sugarcub_erp/sugarcub_inventory/in.php";
  11.  
  12.  
  13. }
  14. //problem in this ajax functions
  15. function ajaxfunctionstore(text){
  16.  
  17.  
  18.     var ajaxRequest;  // The variable that makes Ajax possible!
  19.  
  20.     try{
  21.         // Opera 8.0+, Firefox, Safari
  22.         ajaxRequest = new XMLHttpRequest();
  23.     } catch (e){
  24.         // Internet Explorer Browsers
  25.         try{
  26.             ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  27.         } catch (e) {
  28.             try{
  29.                 ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  30.             } catch (e){
  31.                 // Something went wrong
  32.                 alert("Your browser broke!");
  33.                 return false;
  34.             }
  35.         }
  36.     }
  37.     // Create a function that will receive data sent from the server
  38.     ajaxRequest.onreadystatechange = function(){
  39.         if(ajaxRequest.readyState == 4){
  40.              var  x=ajaxRequest.responseText;
  41.             //alert(x);
  42.              var gettype=x.split("*");
  43.              var  getlen=gettype.length;
  44.              getlen=getlen-1;
  45.              document.forms['store_update_form_entry'].storeno.value = gettype[0];
  46.              document.forms['store_update_form_entry'].storename.value = gettype[1];
  47.              document.forms['store_update_form_entry'].warehousename.value = gettype[2];
  48.              document.forms['store_update_form_entry'].contactperson.value = gettype[3];
  49.              document.forms['store_update_form_entry'].contactno.value = gettype[4];            
  50.              document.forms['store_update_form_entry'].note.value = gettype[5];
  51.  
  52.         }
  53.     }
  54.     var username=text;
  55.     //var wpm = document.getElementById('wpm').value;
  56.     //var sex = document.getElementById('sex').value;
  57.     var queryString = "?username=" + username;
  58.     //alert(queryString); 
  59.     ajaxRequest.open("POST","http://localhost/sugarcub_erp/sugarcub_inventory/storeupdateno.php" + queryString, true);
  60.       ajaxRequest.send(null); 
  61.  
  62. }
  63. function ajaxfunctionstorename(text){
  64.  
  65.  
  66.     var ajaxRequest;  // The variable that makes Ajax possible!
  67.  
  68.     try{
  69.         // Opera 8.0+, Firefox, Safari
  70.         ajaxRequest = new XMLHttpRequest();
  71.     } catch (e){
  72.         // Internet Explorer Browsers
  73.         try{
  74.             ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  75.         } catch (e) {
  76.             try{
  77.                 ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  78.             } catch (e){
  79.                 // Something went wrong
  80.                 alert("Your browser broke!");
  81.                 return false;
  82.             }
  83.         }
  84.     }
  85.     // Create a function that will receive data sent from the server
  86.     ajaxRequest.onreadystatechange = function(){
  87.         if(ajaxRequest.readyState == 4){
  88.              var  x=ajaxRequest.responseText;
  89.             //alert(x);
  90.              var gettype=x.split("*");
  91.              var  getlen=gettype.length;
  92.              getlen=getlen-1;
  93.  
  94.             document.forms['store_update_form_entry'].storeno.value = gettype[0];
  95.              document.forms['store_update_form_entry'].storename.value = gettype[1];
  96.              document.forms['store_update_form_entry'].warehousename.value = gettype[2];
  97.              document.forms['store_update_form_entry'].contactperson.value = gettype[3];
  98.              document.forms['store_update_form_entry'].contactno.value = gettype[4];            
  99.              document.forms['store_update_form_entry'].note.value = gettype[5];
  100.  
  101.  
  102.         }
  103.     }
  104.     var username=text;
  105.     //var wpm = document.getElementById('wpm').value;
  106.     //var sex = document.getElementById('sex').value;
  107.     var queryString = "?username=" + username;
  108.     //alert(queryString); 
  109.     ajaxRequest.open("POST","http://localhost/sugarcub_erp/sugarcub_inventory/storeupdatename.php" + queryString, true);
  110.       ajaxRequest.send(null); 
  111.  
  112. }//problem in this ajax functions//
  113.  
  114.  
  115. function setstoregrade(text)
  116. {
  117. document.getElementById('storegrade').value=text;
  118. }
  119. function showstoreno()
  120. {
  121. document.getElementById('storenoimage').style.display='inline';
  122. document.getElementById('storeselect_div').style.display='inline';
  123. document.getElementById('storeno_div').style.display='inline';
  124. document.getElementById('storenameimage').style.display='none';
  125. document.getElementById('storename_div').style.display='none';
  126. document.getElementById('storenameselect_div').style.display='none';
  127. }
  128. function showstorename()
  129. {
  130.  
  131. document.getElementById('storenoimage').style.display='none';
  132. document.getElementById('storeselect_div').style.display='none';
  133. document.getElementById('storeno_div').style.display='none';
  134. document.getElementById('storenameimage').style.display='inline';
  135. document.getElementById('storename_div').style.display='inline';
  136. document.getElementById('storenameselect_div').style.display='inline';
  137. }
  138. function setwarehousename(text)
  139. {
  140. document.getElementById('warehousename').value=text;
  141. }
[HTML]
</script>
</head>

<body alink="#FFFFFF" vlink="#FFFFFF" link="#FFFFFF" >
<form name="store_update_form_entry" id="store_update_form_entry" action="" method="post" onSubmit="return check(document.department_form_entry)" >
<input type="hidden" name="hidimg" id="hidimg" >
<table width="528" height="370" border="0" align="center" cellpadding="0" cellspacing="0">

<? if($msg=="updated"){?>
<tr>
<td align="center" colspan="2"><font color="#FF0000">store Detail is Updated </font></td>
</tr><? } ?>
<? if($msg=="error"){?>
<tr><td align="center" colspan="2"><font color="#FF0000"><img src="_images/errormessage.gif">Some field not not Filled</font></td></tr><? } ?>
<tr><td>
<table align="right" bgcolor="#A8D3FF" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="font-size:18px; font-weight:bold">EDIT LOCATION </td>
</tr>
</table></td></tr>
<tr><td align="left" colspan="2"><div id="searchstorediv"><fieldset style="border-color:#006699">
<legend class="sugarcube_logo11">Store Search</legend>
<table width="524">
<tr>
<td class="sugarcube_logo11">&nbsp;Search store BY: </td>
//here i call the ajax functions


<td style="font-size:13px; font-weight:bold;cursor:pointer"><font color="#003366"><b onClick="showstorename();">Store Name</b></font><img name="storenameimage" id="storenameimage" src="_images/gif/tick.gif" style="display:none"><b style="font-size:18px">/</b><font color="#003366"><b onClick="showstoreno();">Store No.</b></font><img name="storenoimage" id="storenoimage" src="_images/gif/tick.gif" style="display:none"></td>
</tr>
<tr>
<td width="218" class="sugarcube_logo11"><div id="storename_div" style="display:inline">&nbsp;Store Name</div>
<div id="storeno_div" style="display:none">Store No.</div>.</td>
<td width="294"><div id="storeselect_div" style="display:none"><select name="storenosearch" id="storenosearch" onChange="ajaxfunctionstore(this.value)"><option value="">Select store NO.</option><? echo getstoreno(); ?></select></div>
<div id="storenameselect_div" style="display:inline">
<select name="storesearchname" id="storesearchname" onChange="ajaxfunctionstorename(this.value)">
<option value="">Select store Name</option>
<? echo getstorename(); ?>
</select>
</div></td></tr></table>
</fieldset></div></td></tr>
<tr><td width="528" height="335" valign="top"><fieldset style="border-color:#006699">

<legend class="salary_text21">Store Details</legend>
<table width="524" border="0" cellspacing="0" cellpadding="0">

<tr>
<td width="524" height="186" colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5" colspan="3"></td>
</tr>
<tr>
<td height="20" class="sugarcube_logo11">&nbsp;Store No.:</td>
<td width="135"><input name="storeno" id="storeno" type="text" class="style1"></td>
<td width="162">&nbsp;</td>
</tr>
<tr>
<td height="20" class="sugarcube_logo11">&nbsp;Store Name:</td>
<td><input name="storename" id="storename" type="text" class="style1"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="227" height="20" class="sugarcube_logo11">&nbsp;Warehouse Name :</td>
<td><input name="warehousename" id="warehousename" type="text" class="style1" readonly></td>
<td><select name="warehouseselect" id="warehouseselect" style="width:120px" onChange="setwarehousename(this.value);">
<option value="select">Select Warehouse</option>
<?=getwarehousename();?>
</select></td>
</tr>

<tr>
<td width="227" height="20" class="sugarcube_logo11">&nbsp;Contact Person: </td>
<td><input name="contactperson" id="contactperson" type="text" class="style1"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="227" height="20" class="sugarcube_logo11">&nbsp;Contact No :</td>
<td><input name="contactno" id="contactno" type="text" class="style1"></td>
<td>&nbsp;</td>
</tr>


<tr>
<td height="69" class="sugarcube_logo11">&nbsp;Note:</td>
<td colspan="2"><textarea name="note" id="note" cols="40" rows="4"></textarea></td>
</tr>

<tr bordercolor="#006699">
<td colspan="3" align="RIGHT"><input type="submit" name="Submitstore" id="Submitstore" value="Update"> <input type="submit" name="Submitstore2" id="Submitstore2" value="Delete"> <input type="button" name="back" id="back" value="Back To Main Page" onClick="backtomain();"></td>
</tr>


</table></td>
</tr>
</table>
</fieldset>
</td>
</table>

</form>
<div align="center">[/HTML]
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function check(frm)
  3. {
  4. var out="";
  5.     if(frm.department_name.value==""){
  6.     document.getElementById('department_name_text_error').innerHTML='&bull;Please Fill Department Name';
  7.     out=1
  8.     }
  9. if(frm.department_id.value==""){
  10.     document.getElementById('department_id_text_error').innerHTML='&bull;Please Fill Department Id';
  11. out=1
  12.     }
  13.     if(frm.department_role.value==""){
  14.     document.getElementById('department_role_text_error').innerHTML='&bull;Please Fill Department Role';
  15. out=1
  16.     }
  17.     if(frm.department_date.value==""){
  18.     document.getElementById('department_date_text_error').innerHTML='&bull;Please Fill Department Date';
  19. out=1
  20.     }
  21.     if(frm.department_by.value==""){
  22.     document.getElementById('department_by_text_error').innerHTML='&bull;Please Fill Department By';
  23. out=1
  24.     }
  25.  
  26. if(out=="")
  27.         return true;
  28.     else
  29.         return false;
  30.  
  31. }
[HTML]
</script>
</div>
</body>
</html>[/HTML][PHP]
<?

function getstoreno()
{

$sql="select * from store_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{

$select="";
$str.="<option value='".trim($fetch['storeid'])."'$select>".$fetch['storeid']."</option>";
}

return $str;

}
function getstorename()
{

$sql="select * from store_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{

$select="";
$str.="<option value='".trim($fetch['storename'])."'$select>".$fetch['storename']."</option>";
}

return $str;

}

function getwarehousename()
{

$sql="select * from warehouse_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{

$select="";
$str.="<option value='".trim($fetch['warehousename'])."'$select>".$fetch['warehousename']."</option>";
}

return $str;

}
?>


and this the the php file used in ajax function:
Storeupdatename:
<?
global $str;

$storename=$_REQUEST['username'];
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("sugarcub_inventory");
$sql="select * from store_info where storename='$storename'";
$rs=mysql_query($sql) or die("ERROR - ".mysql_error());
while($fetch=mysql_fetch_array($rs))
{
$str.=$fetch['storeid']."*".$fetch['storename']."*".$fetch['warehouse']."*".$fetch['contactperson']."*".$fetch['contactno']."*".$fetch['note']."*";
}


echo $str;
?>

Storeupdateno:
<?
global $str;

$storeno=$_REQUEST['username'];
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("sugarcub_inventory");
$sql="select * from store_info where storeid='$storeno'";
$rs=mysql_query($sql) or die("ERROR - ".mysql_error());
while($fetch=mysql_fetch_array($rs))
{
$str.=$fetch['storeid']."*".$fetch['storename']."*".$fetch['warehouse']."*".$fetch['contactperson']."*".$fetch['contactno']."*".$fetch['note']."*";
}


echo $str;
?>[/PHP]
Sep 16 '07 #1
2 3113
pbmods
5,821 Expert 4TB
shivendravikramsingh, start using CODE tags. Now.

[CODE=php]
PHP code goes here.
[/CODE]
Sep 16 '07 #2
acoder
16,027 Expert Mod 8TB
You're making a POST request and sending the parameters using the URL. Either make it a GET request or send the parameters using the send method.
Sep 16 '07 #3

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

Similar topics

12
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query...
3
by: equazcion | last post by:
Hi, I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
1
by: shivendravikramsingh | last post by:
hello friends, actually i have a problem in using conditional statement in ajax function i m tring to describe my problem properly,what i want when i select a value form a combo its vlue is passed...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
1
by: violinandviola | last post by:
I have just put 4 different ajax bits on this page: http://jimpix.co.uk/default-ajax.asp The ajax spits out chunks of images / news content, and users can view the chunks via next / prev links....
3
rizwan6feb
by: rizwan6feb | last post by:
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to...
3
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
5
RamananKalirajan
by: RamananKalirajan | last post by:
Hi those who were working in Ajax, will surely experienced with this problem. SOP - Single Origin Policy problem. I am doing a small work in Prototype Ajax. I did a sample work. When I am passing the...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.