<SCRIPT language=JavaScript>
function reload(form)
{
var val=populate.countryList.options[populate.countryList.options.selectedIndex].value;
self.location='deneme.php?countryId=' + val ;
}
</script>
<?php
/*
- Function to return the Country list as an array
- The array can be generated from a database resultset
*/
function getCountryList()
{
// Country List array
$countryList = array (
'1' => 'Bangladesh',
'2' => 'USA',
'3' => 'UK'
);
return $countryList;
}
/*
- Function to return the City list as an array
- Country ID is used to generate the city list
*/
function getCityList($countryId)
{
// City list array
// First key of the array is the Country ID, which holds an array of City list
$cityList = array (
'1' => array ('Dhaka', 'Chittagong', 'What else'),
'3' => array ('London', 'Cannot Remember'),
'2' => array ('Washington', 'N.Y.', 'etc')
);
return $cityList[$countryId];
}
?>
<form action="deneme.php" name="populate">
<?
// Retrieving the country list
$countryList = getCountryList();
// Setting the variable if the country is selected for its city list
@$countryId = $_GET['countryId'];
// Retrieving the city list if a country is selected
$cityList = ($countryId) ? getCityList($countryId) : lisanssız;
if (!empty($countryList))
{
// Generating the country drop down menu
echo "<select onChange='reload(this.form)' name='countryList'>";
foreach ($countryList as $key => $value)
{
echo "<option value='$key'";
if ($countryId == $key)
echo "selected";
echo ">$value</option>";
}
echo "</select>";
}
if (!empty($cityList))
{
// Generating the city drop down menu if a country is selected
echo "<select name='cityList'>";
foreach ($cityList as $key => $value)
{
echo "<option value='$key'>$value</option>";
}
echo "</select>";
}
?>
</form>
<form method=post action=sonuc.php >
<div class="vacsearch">
<div class="vacsearch_in" style="background: url(/test/_resx/images/vacsearch/bg-uk.gif); #0185a8 no-repeat left top">
<h2>
</h2>
<div class="clear">
</div>
<fieldset>
<legend></legend>
<div class="col_half floatl">
<p>
<?php
echo "<form name=sel>\n";
echo "<font id=states><select >\n";
echo "<option value='0'>Sektörler (Hepsi)</option> \n" ;
echo "</select></font>\n";
?>
</p>
</div>
<div class="col_half floatr" style="width: 221px; height: 149px">
<p>
<?php
echo "<font id=cities><select style='width: 214px;'>\n";
echo "<option value='0'>Alt Sektörler (Hepsi)</option> \n" ;
echo "</select></font>\n";
?>
<script language=Javascript>
function Inint_AJAX() {
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
alert("XMLHttpRequest not supported");
return lisanssız;
};
function dochange(src, val) {
var req = Inint_AJAX();
req.onreadystatechange = function () {
if (req.readyState==4) {
if (req.status==200) {
document.getElementById(src).innerHTML=req.responseText; //retuen value
}
}
};
req.open("GET", "sektor_alt_sektor.php?data="+src+"&val="+val); //make connection
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=windows-1254"); // set Header
req.send(lisanssız); //send value
}
window.onLoad=dochange('states', -1); // value in first dropdown
</script>
</p>
<p>
<select size='1' name='sehir' style='width: 214px; '>
<option selected value="">Şehirler (Hepsi)</option>
<?php
$sorgu = mysql_query('SELECT * FROM sehirler ORDER BY sehir ASC');
while ($cek = mysql_fetch_array($sorgu)) {
$sehir = $cek[sehir];
echo "<option value='$cek[sehir]' >$cek[sehir]</option>";
}
?>
</select>
</p>
<p>
<select size='1' name='is_tipi' style='width: 214px; '>
<option value="" selected>İş Türü (Hepsi)</option>
<option value="Daimi">Daimi</option>
<option value="Geçici">Geçici</option>
<option value="Sözleşmeli">Sözleşmeli</option>
</select>
</p>
<p>
<input onblur="if (this.value == '') this.value = 'Anahtar Kelime'" onfocus="if (this.value == 'Anahtar Kelime') this.value=''" size=20 value="Anahtar Kelime" name="kelime" style='width: 208px; ' >
</p>
<p>
</p>
<div class="button2 floatr">
<input type="submit" name="ctl00$MainContent$UxDefault$uxSearch" value="Ara" id="ctl00_MainContent_UxDefault_uxSearch" />
</div>
<p>
</p>
</div>
<div class="clear">
<!-- -->
</div>
</fieldset>
</div>
</div></form>
<?
include ("ayar.php");
//set IE read from page only not read from cache
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header("content-type: application/x-javascript; charset=windows-1254");
$data=$_GET['data'];
$val=$_GET['val'];
if ($data=='states') { // first dropdown
echo "<select name='states' style='width: 214px;' onChange=\"dochange('cities', this.value)\">\n";
echo "<option value=''>Sektörler (Hepsi)</option>\n";
$result=mysql_db_query($dbname,"select `id`, `sektor` from sektorler order by `id`");
while(list($id, $name)=mysql_fetch_array($result)){
echo "<option value=\"$id\" >$name</option> \n" ;
}
} else if ($data=='cities') { // second dropdown
echo "<select name='cities' style='width: 214px;' >\n";
echo "<option value=''>Alt Sektörler (Hepsi)</option>\n";
$result=mysql_db_query($dbname,"SELECT `id`, `alt_sektor` FROM alt_sektorler WHERE `sektor_id` = '$val' ORDER BY `id` ");
while(list($id, $name)=mysql_fetch_array($result)){
echo "<option value=\"$id\" >$name</option> \n" ;
}
}
echo "</select>\n";
?>
Örnek : http://bursaspor.web.tr/deneme.php
istediğin bu şekil bir şey sanırım ufukçum.
PHP:<SCRIPT language=JavaScript> function reload(form) { var val=populate.countryList.options[populate.countryList.options.selectedIndex].value; self.location='deneme.php?countryId=' + val ; } </script> <?php /* - Function to return the Country list as an array - The array can be generated from a database resultset */ function getCountryList() { // Country List array $countryList = array ( '1' => 'Bangladesh', '2' => 'USA', '3' => 'UK' ); return $countryList; } /* - Function to return the City list as an array - Country ID is used to generate the city list */ function getCityList($countryId) { // City list array // First key of the array is the Country ID, which holds an array of City list $cityList = array ( '1' => array ('Dhaka', 'Chittagong', 'What else'), '3' => array ('London', 'Cannot Remember'), '2' => array ('Washington', 'N.Y.', 'etc') ); return $cityList[$countryId]; } ?> <form action="deneme.php" name="populate"> <? // Retrieving the country list $countryList = getCountryList(); // Setting the variable if the country is selected for its city list @$countryId = $_GET['countryId']; // Retrieving the city list if a country is selected $cityList = ($countryId) ? getCityList($countryId) : lisanssız; if (!empty($countryList)) { // Generating the country drop down menu echo "<select onChange='reload(this.form)' name='countryList'>"; foreach ($countryList as $key => $value) { echo "<option value='$key'"; if ($countryId == $key) echo "selected"; echo ">$value</option>"; } echo "</select>"; } if (!empty($cityList)) { // Generating the city drop down menu if a country is selected echo "<select name='cityList'>"; foreach ($cityList as $key => $value) { echo "<option value='$key'>$value</option>"; } echo "</select>"; } ?> </form>