here are my codes
searchByCategoryForm.php -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
<title></title>
-
<link rel="stylesheet" type="text/css" href="style2.css" />
-
<script type="text/javascript" src="init.js"></script>
-
<script type="text/javascript" src="search.js"></script>
-
</head>
-
<body onload='initRequest()'>
-
<div>
-
Search By:<select name="category" id="category" onChange="searchCategory()">
-
<option value="name">Name</option>
-
<option value="serviceID">ServiceID</option>
-
</select>
-
<input name="search" type="text" id='search' size="40" onKeyup="searchCategory()">
-
<div id="searchResult"></div>
-
</div>
-
</body>
-
</html>
-
init.js -
var http;
-
function initRequest()
-
{
-
if (window.XMLHttpRequest)
-
{
-
http = new XMLHttpRequest();
-
}
-
else if (window.ActiveXObject)
-
{
-
http = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
}
-
search.js -
function searchCategory()
-
{
-
var category=document.getElementById("category").value;
-
-
-
if (category=='serviceID')
-
{
-
if(document.getElementById("search").value.length==2)
-
{
-
var format=(document.getElementById("search").value)+"-LP-"
-
document.getElementById("search").value=format;
-
}
-
}
-
var snput=document.getElementById("search").value;
-
var params="category="+category+"&nput="+snput;
-
var url="searchByCategory.php";
-
searchCat(url,params);
-
}
-
-
function searchCat(url,params)
-
{
-
http.open("POST", url, true);
-
-
//Send the proper header information along with the request
-
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
http.setRequestHeader("Content-length", params.length);
-
http.setRequestHeader("Connection", "close");
-
-
http.onreadystatechange = function()
-
{//Call a function when the state changes.
-
if(http.readyState == 4 && http.status == 200)
-
{
-
-
x=http.responseText;
-
document.getElementById("searchResult").innerHTML=x;
-
-
}
-
}
-
http.send(params);
-
}
-
searchByCategory.php -
-
<?php
-
include 'config/opendb.php';
-
-
$category = $_POST['category'];
-
$nput=$_POST['nput'];
-
-
if($category == 'name')
-
{
-
$searchQuery = "SELECT ServiceID, ClientLastName, ClientFirstName
-
FROM service a, client b
-
WHERE a.ClientID = b.ClientID
-
AND CONCAT(ClientLastName,',', ClientFirstName) LIKE '$nput%'";
-
}
-
-
elseif($category == 'serviceID')
-
{
-
$searchQuery = "SELECT ServiceID, ClientLastName, ClientFirstName
-
FROM service a, client b
-
WHERE a.ClientID = b.ClientID
-
AND ServiceID LIKE '$nput%'";
-
-
}
-
$res = mysql_query($searchQuery) or die("Error:searchCategory.php--->".mysql_error());
-
$ctr=0;
-
echo "<table cellspacing='1' style='width:100%;>
-
<tr><font color='black'>
-
<td bgcolor='#E7ECFD' width='100' align='center'><strong>ServiceID</strong></td>
-
<td bgcolor='#E7ECFD' width='400' align='center'><strong>LastName</strong></td>
-
<td bgcolor='#E7ECFD' width='400' align='center'><strong>FirstName</strong></td>
-
<td bgcolor='#E7ECFD' width='200' align='center'><strong>Service Proposal</strong></td>
-
</font></tr>";
-
while(list($serviceID, $clientLastName, $clientFirstName)=mysql_fetch_array($res))
-
{
-
if($ctr%2==0)
-
{
-
echo "<form action='serviceProposal.php' method=POST><tr><font color='black'>
-
<td bgcolor='#CCCCCC' width='100' align='center'>$serviceID<input type=hidden name=\"serviceID\" value=\"$serviceID\"></td>
-
<td bgcolor='#CCCCCC' width='400' align='center'>$clientLastName<input type=hidden name=\"clientLastName\" value=\"$clientLastName\"></td>
-
<td bgcolor='#CCCCCC' width='400' align='center'>$clientFirstName<input type=hidden name=\"clientFirstName\" value=\"$clientFirstName\"></td>
-
<td bgcolor='#CCCCCC' width='200' align='center'><input type=submit name='serviceProposal' value='Create Service Proposal''></td>
-
</font></tr></form>";
-
-
}
-
else
-
{
-
echo "<form action='bookingOrder.php' method=POST><tr><font color='black'>
-
<td bgcolor='#CEE7FF' width='100' align='center'>$serviceID<input type=hidden name=\"serviceID\" value=\"$serviceID\"></td>
-
<td bgcolor='#CEE7FF' width='400' align='center'>$clientLastName<input type=hidden name=\"clientLastName\" value=\"$clientLastName\"></td>
-
<td bgcolor='#CEE7FF' width='400' align='center'>$clientFirstName<input type=hidden name=\"clientFirstName\" value=\"$clientFirstName\"></td>
-
<td bgcolor='#CEE7FF' width='200' align='center'><input type=submit name='serviceProposal' value='Create Service Proposal' onClick='showserviceproposalform()'></td>
-
</font></tr></form>";
-
}
-
$ctr++;
-
}
-
print "</table>";
-
-
include 'config/closedb.php';
-
?>
-
my database is -
CREATE TABLE `client` (
-
`ClientID` int(11) NOT NULL AUTO_INCREMENT,
-
`ClientFirstName` varchar(50) NOT NULL,
-
`ClientLastName` varchar(50) NOT NULL,
-
PRIMARY KEY (`ClientID`)
-
)
-
-
-
CREATE TABLE `service` (
-
`ServiceID` varchar(14) NOT NULL,
-
`ClientID` int(11) DEFAULT NULL,
-
)
-
i dont know whats the problem but base on my observation the code didn't go to database..Please help
any suggestions are very appreciated..thanks
9 2376
Are there any error messages?
Try seeing what you're passing through and the response using Firebug.
Hi acoder,
Thanks for response, Im using firebug and it returns ok,no error message, and i dont know what is my error,values are passing correctly but my problem is why my codes can't connect to my mysql query. if i run manually my query codes it runs properly so any idea?
Thanks,
ghop'z
OK, so what's the response from the server?
Have you tried a normal form with post, e.g. - <form action="searchByCategory.php" method="post">
-
<select name="category" id="category">
-
<option value="name">Name</option>
-
<option value="serviceID">ServiceID</option>
-
</select>
-
<input name="nput" type="text" id='search' size="40">
-
<input type="submit" value="Submit">
-
</form>
Does that produce the required output?
@acoder
Hi acoder,
POST http://127.0.01/BOSS/searchByCategory.php 200 OK 24ms
this is the response from the server.
Yap, i try it and it run properly. i dont my error in my ajax..i cant run it properly in in firefox v3.6 but it works as i want it in ie and chrome.
thank,
ghop'z
OK, but what's the actual response, i.e. the output from the server script?
@acoder
Hi acoder,
the output shows properly as i wanted it..
thanks,
ghop'z
That means that part's working and now we're left with the onreadystatechange call back function. On lines 34-5, add breakpoints and watch the variables concerned, i.e. x.
Try alerting the http.responseText, try setting the "searchResult" div to "test", and so on.
Hi acoder,
Im done on what you said. the values from alert box are correct and but it didn't display on the firefox browser but it is displayed on chrome and ie..
Thanks,
ghop'z
That's strange. Try something like this: - document.getElementById("searchResult").innerHTML="Test";
in place of setting it to x. If the responseText is set correctly, I can't imagine why it wouldn't be set correctly unless it's not getting the searchResult div for some reason.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Danny R |
last post by:
I have the following javascript which works in either IE or Firefox but
not on both.
When I set the code to
http_request.open('POST', url, true) - Works in IE only
http_request.open('GET',...
|
by: nuchphasu |
last post by:
Hi
I have a problem on Dropdownlist that connect database
and retrieve data by Ajax.I write javascript like this
-------------------------------------------------------------------------...
|
by: benoypaul |
last post by:
I have the following javascripts which is working in IE, but not working in Firefox and opera.
var xmlhttp=null;
function showCustomer(str)
{
xmlhttp=getxmlhttp();
if (xmlhttp==null)
{...
|
by: buss123 |
last post by:
Hi all,
combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
|
by: rajasree |
last post by:
Hi all,
am doing a project in PHP. my javascript code is working properly in ie. But its not working in firefox. Please help me
my code is as follows;
<script language="javascript"...
|
by: agbee1 |
last post by:
Hello:
I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
|
by: Mark B |
last post by:
This is my first try at using AJAX. I want the calendars to be enabled if
the user checks CheckBox1. It works OK for a normal all page refresh but
once I introduced the AJAX code it stopped...
|
by: krishna.tunikipati |
last post by:
Hi
I have updated my firefox browser from 2.0 to 3.0
My AJAX functionality is not working in firefox3.0
But in firefox2.0 it worked fine. and working fine in all IE versions
Plz give me a...
|
by: waqasahmed996 |
last post by:
hi
when i use ajax for sending a request on another server then it is not working in firefox. my code is
var url="http://www.example.php"
url=url+"?m="+m
url=url+"&sid="+Math.random()
this...
|
by: waqasahmed996 |
last post by:
hi
i am trying to send an information to a page which is on another server.
var url="http://www.example/.php"
this request is working properly on IE but not working on firefox
firefox is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |