2016年1月23日 星期六

codecharge 設計一個grid 後面,不同的按鈕形狀

想要設計一個效果:在Grid 資料表裡面,每一筆記錄,因為資料狀泰不同,而有不同的按鈕。
按鈕是一個連結到另一個網頁,伴隨著一些連結參數。

原本使用Code Charge 的 Link Control,然後在該Grid 的 BeforeShowRow Event 中進行設定:
$grids->link1->SetValue("some thing");
結果發現,都失敗了!連結的文字,跟本都不理我。

後來,看了 CCS的 help 檔案,裡面有一個範例是這樣的:

<a href="{label1}?parameter={label2}">{label3}</a>

也就是根本就捨棄使用CCS內的 Link Control,而是使用html,裡面的一些設定,完全自己使用label來控制。這引發我很多想法。
Bootstarp 裡面,可以有很多現成的可以使用效果:
<a href=.....> 也可以使用 class="btn btn-primary",這樣一來,Link也有按鈕的效果。
class="btn btn-primary disabled" 就可以使該連結失效!
而這些值都可以在
BeforeShowRow Event 中依據需要而自由設定。
這樣就解決問題了!

2016年1月12日 星期二

CodeChargeStudio!!! button onclick bug!?

設計了一個 record form,裡面有 button ,
可是為什麼設計了一個 on-click event,卻抓不到該筆 records 的欄位?

奇怪?!




2015年12月21日 星期一

2015年12月19日 星期六

jQuery AJAX

jQuery AJAX Methods

AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.
The following table lists all the jQuery AJAX methods:
MethodDescription
$.ajax()Performs an async AJAX request
$.ajaxPrefilter()Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax()
$.ajaxSetup()Sets the default values for future AJAX requests
$.ajaxTransport()Creates an object that handles the actual transmission of Ajax data
$.get()Loads data from a server using an AJAX HTTP GET request
$.getJSON()Loads JSON-encoded data from a server using a HTTP GET request
$.getScript()Loads (and executes) a JavaScript from a server using an AJAX HTTP GET request
$.param()Creates a serialized representation of an array or object (can be used as URL query string for AJAX requests)
$.post()Loads data from a server using an AJAX HTTP POST request
ajaxComplete()Specifies a function to run when the AJAX request completes
ajaxError()Specifies a function to run when the AJAX request completes with an error
ajaxSend()Specifies a function to run before the AJAX request is sent
ajaxStart()Specifies a function to run when the first AJAX request begins
ajaxStop()Specifies a function to run when all AJAX requests have completed
ajaxSuccess()Specifies a function to run when an AJAX request completes successfully
load()Loads data from a server and puts the returned data into the selected element
serialize()Encodes a set of form elements as a string for submission
serializeArray()Encodes a set of form elements as an array of names and values

AJAX

AJAX 概念:

AJAX




Create an XMLHttpRequest Object



var xhttp;
if (window.XMLHttpRequest) {
    xhttp = new XMLHttpRequest();
    } else {
    // code for IE6, IE5    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}


Send a Request To a Server






Server Response






The onreadystatechange Event








<!DOCTYPE html>
<html>
<body>

<h3>Start typing a name in the input field below:</h3>

<form action=""> 
First name: <input type="text" id="txt1" onkeyup="showHint(this.value)">
</form>

<p>Suggestions: <span id="txtHint"></span></p> 

<script>
function showHint(str) {
  var xhttp;
  if (str.length == 0) { 
    document.getElementById("txtHint").innerHTML = "";
    return;
  }
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      document.getElementById("txtHint").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET", "gethint.php?q="+str, true);
  xhttp.send();   
}
</script>

</body>
</html>



showCustomer

function showCustomer(str) {
  var xhttp; 
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
  }
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
    document.getElementById("txtHint").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET""getcustomer.asp?q="+str, true);
  xhttp.send();
}




2015年12月9日 星期三

DataSource->Where

如果 在 Design Type 下,該筆  Record 的 DataSource 裡面的 WHERE 有設定值
則 Run Time 時,似乎無法改變 DataSource->Where 的值

如果 在 Design Mode 裡, Record 的 DataSource 沒有設 Where
Run time ,在 BeforeBuildSelect Event 就可以設定 Where 值!

2015年12月7日 星期一

快速訂單設計記錄

這篇是寄給我自己看的,讀者看不懂就算了!

在資料庫中讀取相同的介紹會員,且還沒有完成的快速訂單中,找出最近的一筆,亦即是 id 最大的那筆,然後,設定一個 Session 給他。

在 STEP1 Page 中的 PageBeforeInitialize 中,寫:
$db = new clsDBmysql_conn(); 
$SQL = "SELECT max(qf_id) as maxid FROM quick_form WHERE refer_mem_extid='" .$_SESSION["mem_id"]."' AND finished='0';";
$db->query($SQL);
$Result = $db->next_record(); 
if ($Result) {$_SESSION["qf_id"] = $db->f("maxid");} else {$_SESSION["qf_id"] = 0;}

然後,在 Page 的 Record 中,DataSource 中,要設定該 Table ,Where 設定為:qf_id=$_SESSION["qf_id"];

這樣就可以搞定。

STEP 2, STEP 3....之後的步驟網頁,也都是一樣的設定,這樣就可以確保處裡的都是相同的一筆資料了!

上一步、下一步,都可以指稱到相同的一筆。縱使是 user 直接在 url 輸入 step2網址,也可以指到我們希望的那一筆資料。(相同會員最後未完成的那一筆記錄)。

注意:當最後一個步驟完成時,記得必需將 Finished 欄位設為"1",且將 Session 清空!表示已經完成,不會被重複處理!


如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。 如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。 以上。