使用Ajax和PHP更改下拉列表值 [英] Changing dropdown list values using Ajax and PHP

查看:56
本文介绍了使用Ajax和PHP更改下拉列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
填充下拉菜单-PHP Ajax MySQL

Possible Duplicate:
Populating dropdown - PHP Ajax MySQL

我有4个下拉列表元素,它们应该相互组合,关于目的地.第一个应该具有所有目的地,然后根据用户选择的第二个下拉列表具有要选择的城市可用的值(目的地),然后其他两个下拉列表将具有与该目的地相反的方式.它类似于此网站中的表单: http://info.airprishtina.com/content/index.php?id = 20& no_cache = 1& L = 0 (您可以在左侧的示例中看到一个bookig表单).我需要ajax脚本来执行此操作.我将处理PHP任务.

I have 4 dropdown list elements and they should be combined with each other, its about destinations. the first one should have all destinations and then depending on what the user selects the second dropdown list with have the values(destinations) that are available for the selected city, then the 2 other dropdown lists will have the opposite way of that destination. its something like the form in this web site: http://info.airprishtina.com/content/index.php?id=20&no_cache=1&L=0 (you can see the example in the left side there is a bookig form). I need the ajax script to do this. I will take care of the PHP task.

<div class="WraperForForm"> 
<form action="index.php?menu=rezervimet&submenu=rezervo" method="post">

<table  cellspacing="5" cellpadding="0" border="0" >
<tr>
    <td width="100">
        Emri:
    </td>
    <td width="190">
        <input type="text" id="emri" name="emri">
    </td>

    <td width="100">
        Mbiemri:
    </td>
    <td width="190">
        <input type="text" id="mbiemri" name="mbiemri">
    </td>
</tr>
</table>

<table width="300" cellspacing="5" cellpadding="0" border="0" style="float:left;">
<tr>
    <td width="100">
        Prej:
    </td>
    <td>
        <select class="selectDest" name="Prej">
            '.funksionet::directions(1).'
        </select>
    </td>

</tr>
<tr>
    <td width="80">
        Deri:
    </td>
    <td>
        <select class="selectDest" name="Deri">
            '.funksionet::directions(2).'
        </select>
    </td>
</tr>
<tr>
    <td>

            <form name="Data1Drejtim">
            <label for="data1drejtim">Data e nisjes:</label>
    </td>
        <td>
            <input type="text" id="data1drejtim" name="data1drejtim">
            <script language="JavaScript">


    // whole calendar template can be redefined per individual calendar
    var A_CALTPL = {
        \'months\' : [\'Janar\', \'Shkurt\', \'Mars\', \'Prill\', \'Maj\', \'Qershor\', \'Korrik\', \'Gusht\', \'Shtator\', \'Tetor\', \'Nentor\', \'Dhjetor\'],
        \'weekdays\' : [\'Di\', \'He\', \'Ma\', \'Me\', \'Ej\', \'Pr\', \'Sh\'],
        \'yearscroll\': true,
        \'weekstart\': 0,
        \'centyear\'  : 70,
        \'imgpath\' : \'images/\'
    }

    new tcal ({
        // if referenced by ID then form name is not required
        \'controlname\': \'data1drejtim\'
    }, A_CALTPL);
    </script>

    </td>

    </tr>
</table>

<!-- ___________________Return table_____________________________________ -->
<table width="300" cellspacing="5" cellpadding="0" border="0" style="float:left;" id="hideThis" >
<tr>
    <td width="100">
        Prej:
    </td>
    <td>
        <select class="selectDest" name="KthyesePrej" >
                '.funksionet::directions(2).'
        </select>
    </td>
</tr>
<tr>
    <td width="40">
        Deri:
    </td>
    <td>
        <select class="selectDest" name="KthyeseDeri">
            '.funksionet::directions(1).'
        </select>
    </td>

<tr>
    <td>
        <label for="dataKthyese">Data kthyese:</label>
    </td>       

    <td>

            <input type="text" id="dataKthyese" name="dataKthyese">
                <script language="JavaScript">


    // whole calendar template can be redefined per individual calendar
    var A_CALTPL = {
        \'months\' : [\'Janar\', \'Shkurt\', \'Mars\', \'Prill\', \'Maj\', \'Qershor\', \'Korrik\', \'Gusht\', \'Shtator\', \'Tetor\', \'Nentor\', \'Dhjetor\'],
        \'weekdays\' : [\'Di\', \'He\', \'Ma\', \'Me\', \'Ej\', \'Pr\', \'Sh\'],
        \'yearscroll\': true,
        \'weekstart\': 0,
        \'centyear\'  : 70,
        \'imgpath\' : \'images/\'
    }

    new tcal ({
        // if referenced by ID then form name is not required
        \'controlname\': \'dataKthyese\'
    }, A_CALTPL);
    </script>
            </form>
        </td>

</tr>
</table>

<table width="585" cellspacing="0" cellpadding="3" border="0 " style="float:left;">
<tr>
    <td >Persona:</td>
    <td>
        <select>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        </select>
    </td>
</tr>
<tr>
    <td width="100">
        <input type="radio" id="1drejtim" name="drejtimi"  value="një drejtim" onclick="toggleVisibility(\'hideThis\',0)">
        <label for="1drejtim">Një drejtim</label>
    </td>

    <td >
        <input type="radio" id="kthyese" name="drejtimi" checked="checked" value="kthyese"  onclick="toggleVisibility(\'hideThis\',1)">
        <label for="1drejtim">Kthyese</label>
    </td>

    <td>
    <input style="float:right;" type="submit" value="Rezervo" name="rezervo" />
    </td>
</tr>
</table>
</form><!-- end of the reservation form-->
</div>

这是代码的一部分,当我启动它时,我忘记了人们将能够从附近的城市或从国外进行预订,因此我仅对国内城市进行FROM下拉列表,而对国外城市进行TO下拉列表城市.无论如何,我需要用ajax来完成所有这些工作,因为我对ajax一点都不擅长!

this is part of the code, when I started it I forgot that people will be able to make reservation from cities near them or from abroad, so I made the FROM dropdown only with the domestic cities and the TO dropdown list with foreign cities. anyway I need all this with ajax because I am not good at all with ajax!

谢谢您的时间.

推荐答案

我将通过引用外包文章中引用的一些代码来提供帮助,但我决定仅向您提供直接链接,使我了解您的想法寻找.在这里是:

i was about to help by referring to some code cited from an outsourced article, but I have decided just to give you a direct link to what I think you are looking for. here it is: populating triple dropdown list

这篇关于使用Ajax和PHP更改下拉列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆