what am i doing wrong?
i want to populate the country list according to the category
i want to switch in case CategoryID=1 and CatID2=2 in the country_list table
then call on "alpha" to populate the dropdown list via ajax
the form:
Code: <!--
The following file was created by Iwo Kadziela at TECHROAM: http://www.techroam.com
This file uses MySql database and AJAX to create autopopulating dynamic select boxes.
<html>
<head>
<script src="request.js"></script>
<script type="text/javascript">
function getfirst(dd1)
{
clearSelect = document.getElementById('thirdbox');
clearSelect.options.length = 1;
//above code clears the third select box when re-clicking the first select box
var idx = dd1.selectedIndex;
var first = dd1[idx].value;
var par = document.forms["theform"];
var parelmts = par.elements;
var prezsel = parelmts["secondbox"];
if (first != "Select Something One")
{
Http.get({
url: "./alpha.php?alpha=" + first + "%",
callback: fillPrez,
cache: Http.Cache.Get
}, [prezsel]);
}
}
function getsecond(dd1)
{
var idx = dd1.selectedIndex;
var second = dd1[idx].text;
var par = document.forms["theform"];
var parelmts = par.elements;
var prezsel = parelmts["thirdbox"];
if (second != "Select Something Two")
{
Http.get({
url: "./beta.php?state=" + second,
callback: fillPrez,
cache: Http.Cache.Get
}, [prezsel]);
}
}
function fillPrez(xmlreply, prezelmt)
{
if (xmlreply.status == Http.Status.OK)
{
var prezresponse = xmlreply.responseText;
var prezar = prezresponse.split("|");
prezelmt.length = 1;
prezelmt.length = prezar.length;
for (o=1; o < prezar.length; o++)
{
prezelmt[o].text = prezar[o];
prezelmt[o].value = prezar[o];
}
}
else
{
alert("Cannot handle the AJAX call.");
}
}
function getthird(dd1,dd2) {
var idx = dd1.selectedIndex;
var third = dd1[idx].text;
if (third != "Select The Final")
{
Http.get({
url: "./final.php?state=" + dd2 + "&city=" + third,
callback: getit,
cache: Http.Cache.Get
});
}
}
function getit(xmlreply){
if (xmlreply.status == Http.Status.OK)
{
document.getElementById("final").innerHTML= xmlreply.responseText;
}
else
{
alert("Cannot handle the AJAX call.");
}
}
</script>
<style>
body {
width:800px;
margin: 0px auto;
text-align:center;
}
p {display:inline;margin:20px;}
div {clear:both;width:800px;border:1px solid #999;padding:20px;margin:20px 0px 20px 0px;}
</style>
</head>
<body>
<form name="theform">
<p>
<select name="firstbox" size="13" style="position: relative; width: 215px;" onChange="getfirst(this);">
<option value="">Select Something One</option>
<?php
do {
?>
<option value="<?php echo $row_RsCategories['CategoryID']?>"><?php echo $row_RsCategories['CategoryName']?></option>
<?php
} while ($row_RsCategories = mysql_fetch_assoc($RsCategories));
$rows = mysql_num_rows($RsCategories);
if($rows > 0) {
mysql_data_seek($RsCategories, 0);
$row_RsCategories = mysql_fetch_assoc($RsCategories);
}
?>
</select>
</p>
<p>
<select name="secondbox" size="13" style="position: relative; width: 215px;" onChange="getsecond(this);">
<option>Select Something Two</option>
</select>
</p>
<p>
<select id="thirdbox" name="thirdbox" size="13" style="position: relative; width: 215px;" onChange="getthird(this, document.theform.secondbox.options[document.theform.secondbox.selectedIndex].value);">
<option>Select The Final</option>
</select>
</p>
</form>
<center>THE FINAL CONTENT PULLED FROM DATABASE</center>
<div id="final"></div>
</body>
</html>
<?php
mysql_free_result($RsCategories);
?>
alpha.php
Code: </php
$dbconnection = mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("international", $dbconnection) or die("Couldn't open database: ".mysql_error());
$alpha=$_GET['alpha'];
switch ($alpha)
{
case 1:
$result = mysql_query("SELECT CountryName from country_list WHERE CategoryID = '".$_GET['alpha']."'");
break;
case 2:
$result = mysql_query("SELECT CountryName from country_list WHERE CatID2 = '".$_GET['alpha']."'");
break;
while ($row = mysql_fetch_array($result)) {
echo "|" . $row['CountryName'];
}
?>
Not sure why this script is not working?
Hi I am new to php programing and I was trying to make up a simple script like a captcha but I cannot get the validation part of it working. I think it should work but it is not. Anyone know what is
How to add advertisment on top of videos
Hello,I was told that i should find the answer for this problem in this forums.I searched a lot but i couldnt find the solution .What i need to do is to add ads on top of the videos i have
Ajax Issues - Update Panel / Timer. Intellisense doesn't know about them
Type 'System.Web.UI.ScriptManager' does not have a public property named 'UpdatePanel'.
PHP code needed to get/post form fields and request mysql query results.
I'm new to PHP I've created an html form to allow the user to request a basic telephone directory listing. They can select their 'listtype' by 'all' or by 'state'. If they choose 'state' then they
MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an error... and was hoping someone could help me out.You have an error in your SQL syntax; check the manual
Coding Critique
I was hoping someone could take a second and look down my code and see if they see any problems with how it was written before I continue on.Code: <?php require
captcha error
I have been trying to implement a captcha in php...here is the code..Code: (php) [Select]<?php// Set the content-typeheader('Content-type: image/png');// Create the image$im =
Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to put the CRON code do I put it in the header between the head tags? do I put it before any html code?
Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so
Looping Problem
I've got a client that has a database with about 200 events at any given time. I'm trying to loop through the dates based on a form and show the title of the event if the start date of the form