无法使用javascript获得所需的输出

时间:2014-07-28 11:54:19

标签: javascript php

这是html代码

<tr>
    <td class="adsfilterTDSpacing">Ad Property Location</td>
    <td>
        <select name = "AdvFilterId" id = "LocationPagesSlctField" onchange="showCity(this.value)">
<?php
    if ($advFilterId == "1") {
        $selected = "selected = 'selected'";
    } else {
        $selected = "";
    }
    if ($advFilterId == "0") {
        $selected = "selected = 'selected'";
    } else {
        $selected = "";
    }
?>

            <option <?php echo $selected; ?> value = "1"> All Pages</option>
            <option <?php echo $selected; ?> value = "0">Advanced Filter</option>
        </select>
    </td>
</tr>

这是JavaScript代码

function showCity(LocationValue){
    var Locationval = LocationValue;
    //alert (Locationval);
    if(Locationval == '0'){
       document.getElementById('sltcShowCity').style.display='';
    }
    else{
       document.getElementById('sltcShowCity').style.display='none';
    }

}

现在代码出现在我收到错误的地方:

<?php
    $getPostedCityId = isset($_POST['CityId']) ? $_POST['CityId'] : "";
    if ($getPostedCityId != "") {
        $cityStyle = "";
    } else {
        $cityStyle = "display:none";
    }
?>

<tr id="sltcShowCity" style="<?php echo $cityStyle; ?>">
   <td class="adsCityTDSpacing">Select City</td>
   <td>
        <select name="CityId" id="citySlctField" onchange="this.form.submit();">
            <option value = "0">Select City</option>
<?php
    //Get All City
    $allCitySQL = mysql_query("SELECT * FROM cities WHERE publish_bool = 1 AND mark_as_deleted != 1");
    while ($allCityRow = mysql_fetch_array($allCitySQL)) {
        if ($getPostedCityId == $allCityRow['city_id']) {
            $selected = "selected = 'selected'";
        } else {
            $selected = "";
        }
?>

            <option <?php echo $selected; ?> value="<?php echo $allCityRow['city_id']; ?>">
<?php echo $allCityRow['city_name']; ?>
            </option>
<?php

    }
?>
<input type="hidden" name="chkCityId" value="<?php echo $getPostedCityId; ?>" />
        </select>
    </td>
</tr>

我正在使用此代码根据我想要获取位置的城市ID获取城市ID。我正在获取该位置,但当我将广告物业位置中的选项转到所有页面时,我仍然可以获得所选城市的城市价值,我希望它能够选择城市

第二个问题是我希望区域值在我使用的区域中选择为空,复选框。

此处的区号

<?php
    if (($getPostedCityId != "") && ($getPostedCityId > "0")) {
?>
<tr>
   <td class="adsZoneTDSpacing">Select Zone(s)</td>
   <td id="adsZoneTDExtraSpacing">
       <table>
<?php
    $adsPropertyZoneSQL = mysql_query(
                "SELECT * FROM city_zones 
                WHERE city_id = '{$getPostedCityId}' 
                    AND mark_as_deleted != 1 AND publish_bool = 1");
    while ($adsPropertyZoneRowSQL = mysql_fetch_array($adsPropertyZoneSQL)) {
?>

        <tr>
            <td class="adsZoneChkBoxStyle">
                <input type="checkbox" name="adspropertyZone[]" value="<?php echo $adsPropertyZoneRowSQL['city_zone_id']; ?>" onclick="GetLocation(this.value, this.checked)" />
            </td>
            <td class="adsZoneChkBoxNameStyle">
                <?php echo $adsPropertyZoneRowSQL['city_zone_name']; ?>
                <table id ="LocationIds_<?php echo $adsPropertyZoneRowSQL['city_zone_id']; ?>" style="display:none;">
<?php
    $adsPropertyLocationSQL = mysql_query(
            "SELECT * FROM locations 
            WHERE city_id = '{$getPostedCityId}' 
                AND city_zone_id = '{$adsPropertyZoneRowSQL['city_zone_id']}' 
                AND mark_as_deleted != 1 
                AND publish_bool = 1");
    while ($adsPropertyLocationRowSQL = mysql_fetch_array($adsPropertyLocationSQL)) {
?>

            <tr>
                <td class="adsLocationChkBoxStyle">
                    <input type="checkbox" name="adspropertyLocation[]" value="<?php echo $adsPropertyLocationRowSQL['location_id']; ?>" />
                </td>
                <td class="adsLocationChkBoxNameStyle">
                    <?php echo $adsPropertyLocationRowSQL['location_name']; ?>
                </td>
            </tr>
<?php 
    }
?>
            </table>
        </td>
    </tr>
<?php
    }
?>
    </table>
</td>
</tr>

请提前帮助我

0 个答案:

没有答案