English 中文(简体)
2. 变更第一个盒子的选定价值后再设计第二和第三箱
原标题:Populate second and third select box after change the selected value of the first box
  • 时间:2012-01-12 23:08:08
  •  标签:
  • php
  • jquery

有三个选择的箱子,先是“女方”和“女方”。 在选择第一个选箱的价值时,“客户-选择”即使用美元,然后使用人满为患装置。 我的问题是,如果在“我们——选择”的“我们——选择”的数值,那么“问题——选择”的人群,那么什么事情要做。 我认为,在有人试图找人问话时,在计票过程中会发现一些错误。 当改变(或首次选择)装置价值时——很少发生,就没有发生。

某个人可能会发现错误或类型,试图用小时计出这种错误,并且找不到任何东西。

My javascript:

<script type="text/javascript">
    $(document).ready(function()
    {
        $( #device_sel ).attr( disabled , true);
        $( #prob_sel ).attr( disabled , true);


        $( #customer_sel ).change(function()
        {
            var cid = $( #customer_sel ).attr("value");
            $.post("get_customers_devices.php", {cid:cid}, function(data)
            {
                $( #device_sel ).attr( disabled , false);
                $( #device_sel ).html(data);
            });
        });

        $( #device_sel ).change(function()
        {
            var did = $( #device_sel ).attr("value");
            jQuery.post("get_device_problems.php", {did:did}, function(data)
            {
                $( #prob_sel ).attr( disabled , false);
                $( #prob_sel ).html(data);
            });
        });

    });
</script>

:

    <?php

include "FillSelect.class.php";

echo $fill->FillDeviceSelect($getdata->GetCustomersDevice($_POST[ cid ]));

?>

获得:device_problems.php:

 <?php

include "FillSelect.class.php";

echo   $fill- >FillProblemSelect($getdata->GetDeviceProblems($_POST[ did ])) ;

?>

GetCustomerDevice and GetDeviceProblems:

function GetCustomersDevice($cid)
    {
        try
         {
            $db = new PDO( sqlite:base.db ) ;
            $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

            $pquery = $db->prepare("SELECT * FROM Devices WHERE cid=:cid");
            $data = array("cid"=>$cid);
            $pquery -> execute($data) ;

            $rows = $pquery->fetchAll();

            return $rows;
        }
        catch(PDOException $e)
        {
            echo "Failure: " . $e->getMessage();            
        }

        $db = NULL;
    }

    function GetDeviceProblems($did)
    {
        try
         {

            $db = new PDO( sqlite:base.db ) ;
            $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

            $pquery = $db->prepare("SELECT * FROM Problems p, Devices d WHERE d.did=:did");
            $data = array("did"=>$did);
            $pquery -> execute($data) ;

            $rows = $pquery->fetchAll();

            return $rows;
        }
        catch(PDOException $e)
        {
            echo "Failure: " . $e->getMessage();            
        }

        $db = NULL;
    }

最后,FillDeviceSelect和FillProblemSelect:

function FillDeviceSelect($data)
    {
        $device =  <option value="0">Select option</option> ;
        foreach($data as $row)
        {
            $device.=  <option value=" . $row[ did ] . "> . $row[ device_name ] . </option> ;
        }

        return $device;
    }

function FillProblemSelect($data)
    {
        $problem =  <option value="0">Select option</option> ;
        foreach($data as $row)
        {
            $problem .=  <option value="  . $row[ pid ]  . ">  .  $row[ problem ] . </option> ;
        }

        return $problem;
    }

Solved it. Very very silli mistakes, get_device_problems not in same folder as my page but i did know that the file was saved in another folder and thats why my post call didnt work...

问题回答

我并不乐观,但我想象,由于你对<代码>device_sel<<>code>有 on效应,你在用你在<代码>customer_上的传呼将其重新定位为违约值。 请不要约束您从<代码>美元(#device_sel )中作第二次改动(功能,看你是否有同样的问题。 (如果我完全误解你再次提出的问题,我道歉)





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签