作者: Programmer 時間: 2010-11-24 15:41 標題: [問題]JQuery + php@callback and reload data
搞左好耐都唔得
我想整3/4個 dropdown list box (Product category....), 當user change category ge 時候,
會用 php 重新去 database load 過 d product, 但唔要跳畫面
e + 入到 call back success function
但個 Page 無轉到....
有無 example?
作者: kau 時間: 2010-11-24 16:26
Check this out!
http://remysharp.com/2007/09/18/ ... tiple-select-boxes/
作者: Programmer 時間: 2010-11-25 10:02
Thank you for your help...
試左, 唔知點轉做 drop down list box and
唔知點轉 reload page, 個sample 只係 upload 另一個 list box..
作者: bac3bac0mm 時間: 2010-11-25 12:18
提示: 作者被禁止或刪除 內容自動屏蔽
作者: kau 時間: 2010-11-25 12:28
本帖最後由 kau 於 2010-11-25 12:49 編輯
Dropdown:
- <select id="categorySelect" name="category" size="5">
- vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
- <select id="categorySelect" name="category">
當user change category ge 時候,
會用 php 重新去 database load 過 d product, 但唔要跳畫面
唔知點轉 reload page, 個sample 只係 upload 另一個 list box..
你想dynamically generated的data用非select的方式顯示?
html table?咁你可以改select-chain.js,改做auto-generate html table都ok架
作者: Programmer 時間: 2010-11-25 13:10
Dropdown:
你想dynamically generated的data用非select的方式顯示?
html table?咁你可以改select-c ...
kau 發表於 2010-11-25 12:28
Thank you
I don't know how to detect the dropdownlist on change event. and where and how should I place the coding on (Client or server side)?
作者: kau 時間: 2010-11-25 14:12
本帖最後由 kau 於 2010-11-25 14:26 編輯
回復 6# Programmer
in select-chain.php, it *imports/requires/includes* jQuery and the select-chain package when it is rendered in browsers to enable the magic.
You can then find the following JS code. It is the select-chain-package-controller.
You will need to configure it, set the target to fit your design.
- <script type="text/javascript">
- <!--
- $(function () {
- var cat = $('#categorySelect');
- var el = $('#elementSelect');
- var attr = $('#attributeSelect');
-
- el.selectChain({
- target: attr,
- url: 'select-chain.php',
- data: { ajax: true, anotherval: "anotherAction" }
- });
- // note that we're assigning in reverse order
- // to allow the chaining change trigger to work
- cat.selectChain({
- target: el,
- url: 'select-chain.php',
- data: { ajax: true }
- }).trigger('change');
- });
- //-->
- </script>
If you want to display them as Table or whatever, you need to edit select-chain.js. The magic begins on line 31. Below is the code block to inject the dynamic data to the predefined "target" in controller.
- success: function (j) {
- var options = [], i = 0, o = null;
-
- for (i = 0; i < j.length; i++) {
- // required to get around IE bug (http://support.microsoft.com/?scid=kb%3Ben-us%3B276228)
- o = document.createElement("OPTION");
- o.value = typeof j[i] == 'object' ? j[i][settings.key] : j[i];
- o.text = typeof j[i] == 'object' ? j[i][settings.value] : j[i];
- settings.target.get(0).options[i] = o;
- }
作者: Programmer 時間: 2010-11-26 15:23
回復 Programmer
in select-chain.php, it *imports/requires/includes* jQuery and the select-chain pa ...
kau 發表於 2010-11-25 14:12
Thank you
I have been try a day, finally I got a lot of error. one of that is "Object doesn't support this property or method" in php file. May I request again, Please tell me if you have simple example.
作者: Programmer 時間: 2010-11-29 08:49
Push

作者: zetalau 時間: 2010-11-30 01:56
ajax + $(xxx).html() !??
作者: Programmer 時間: 2010-11-30 15:50
????
作者: kau 時間: 2010-11-30 21:50
回復 8# Programmer
Hi,
This is a PHP or Javascript error?
作者: Programmer 時間: 2010-12-1 09:02
Javascript error.
I think I found a solution for solving this problem.
Thank you everyone
作者: kau 時間: 2010-12-1 11:04
回復 13# Programmer
Great!!!
Can you share?

