各國語系公告之部分資料
 
Fornt end
 
<form id="insertform" name="insertform" >
<?php
 if( $this->lang ){ 
   foreach($this->lang as $lang){
?>
      <label class="checkbox-inline">
      <input type="checkbox" name="lang[<?php echo $lang['公告語系ID']?>]" /><?php echo $lang['名稱'];?>
      </label>
<?php
   }
 }
?><label><?php echo $lang['名稱']?>公告標題</label>
<input name="title[<?php echo $lang['公告語系ID']?>]" type="text" class="form-control" ><button onclick="insert()" class="btn btn-warning btn-block" >送出</button>
</form>

 
AJAX
       
<script>
function insert() {
  event.preventDefault(); //使form按下按鈕後不會自行刷新
  var formData = $('#insertform').serialize();
  $.ajax({
    type: 'POST',
    dataType: "json",
    data:{ 
      'formData':formData,
      'act':'insert'
    },
    success: function (data) {
      if(data.result) {
        // 成功時彈出modal,自動刷新
        var modal = $('#succModal')
        $('.modal-title', modal).html(data.detail+',5秒後自動重整,若無自動跳頁<a style="cursor: pointer;" onClick="location.reload()">請點我跳頁</a>')
        modal.modal({
          backdrop: 'static',
          keyboard: false
        }).on('click', 'button.close[type="button"]', function() {
            location.reload();
        }).on('shown.bs.modal', function() {
            setTimeout(function() {
              location.reload();
            }, 5000)
        })
      } else {
        $('#alerttext').text(data.detail+","+data.debug.message)
        $('#inserterror').show()
      }
    },
    error: function(xhr, ajaxOptions, thrownError){
      alert(xhr.status);
      alert(thrownError);
    }
  });
}
</script>
 
 
PHP
            
<?php
parse_str($this->getRequest()->getParam('formData'), $formData);
$starttime=$formData['starttime']; //一般之時間欄位
foreach($lang["data"] as $lang){
  if($formData['lang'][$lang['公告語系ID']]=='on'){
    print($formData['title'][$lang['公告語系ID']]);
  }
}
?>
文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

參考文章之內容

<input accept="image/*" id="uploadImage" type="file">
<img id="img" src="">
<script>
        $("#uploadImage").change(function(){
                readImage( this );
        });
 
        function readImage(input) {
                if ( input.files && input.files[0] ) {
                        var FR= new FileReader();
                        FR.onload = function(e) {
                                //e.target.result = base64 format picture
                        $('#img').attr( "src", e.target.result );
                };       
                FR.readAsDataURL( input.files[0] );
                }
        }
</script>

修改為按下按鈕後才更換

<table>
    <tr>
          <td><input type="file" name="file" accept="image/*" id="uploadImage"/></td>
          <td><button type="submit" class="btn btn-primary" onclick="JavaScript:return Validator();">更換</button></td>
    <tr/>
</table>

<script>
        var upload = document.querySelector('#uploadImage');
        if ( upload.files && upload.files[0] ) {
                alert('test');
                var FR= new FileReader();
                FR.onload = function(e) {
                        //e.target.result = base64 format picture
                        $('#prove_img').attr( "src", e.target.result );
                };
                FR.readAsDataURL( upload.files[0] );
        }
</script>

參考文章:

http://howard10335.blogspot.tw/2015/09/javascripthtml-inputbase64-string.html

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

 

<?php

  if($data['認列等級']==""){

  echo "無認列";

 }else{

  echo $data['認列等級'];

 }

?>

---↓--↓-進-↓--↓-階-↓--↓--↓---

<?php

 echo ($data['認列等級'] =="") ? "無認列" : $data['認列等級']

?>

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

<?php
$array 
= array(=> 'blue'=> 'red'=> 'green'=> 'red');

$key array_search('green'$array); // $key = 2;
$key array_search('red'$array);   // $key = 1;
?>

資料來源:http://php.net/manual/en/function.array-search.php

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

<?php foreach($this->edulictypes as $edulictype): ?>
  <option><?php echo $edulictype["名稱"]?></option>    
 <?php endforeach ?>

 

<?php foreach($this->edudb_types as $d){ ?>
         <option><?php echo $d['category']; ?></option>    
<?php   }  ?>

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

ALTER FUNCTION [dbo].[資料表]
( @帶入變數1 AS VARCHAR(10))
RETURNS @return_table TABLE ( 
    輸出欄位1 INT
)
AS
--先找學生修課清單

BEGIN
    INSERT INTO @return_table (輸出欄位1) 
        SELECT   
        輸出欄位1
        FROM cca.dbo.搜尋資料表 a WHERE a.欄位 = @帶入變數1
                
  RETURN 
END

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

protected $dir= 'C:/AppServ/www/專案/public/power/upload';
protected $url= '../upload/';

給予路徑與檔案要存放位置

select陣列拿出資料將每一筆有無圖片狀況帶入

      $r = $result['rows'];
      //取出證照圖片有無狀態
      $count = count($r);
      for($i=0;$i<$count;$i++){
          $r[$i]['圖片狀態']=0;
          if(file_exists($this->dir.'/'.$this->user->stuid.'.jpg')){
              $r[$i]['圖片狀態']=1;
          }
                        
       }
       $this->view->url =$this->url;
       $this->view->data = $r;

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

當用php的for產生了許多的相同類別的按鈕與需要顯示內容DIV,這時依照原先的程式碼是不會有反應的

原先 修改後

 

<script>
        $(document).ready(function(){
            $(".Show").click(function(){
                $(".Div).show("slow");
                $(".Show).hide();
                $(".Hide).show();
            });
            $("#Hide").click(function(){
                status = $(this).attr("name");
                $(".Div).hide("slow");
                $(".Hide).hide();
                $(".Show).show();
            });
        });
    </script>

點選到類別SHOW會抓取他的name值,

抓取NAME值為相同之DIV來做顯示內容

<script>
        var status="";
        $(document).ready(function(){
            $(".Show").click(function(){
                status = $(this).attr("name");
                $(".Div[name='"+status+"']").show("slow");
                $(".Show[name='"+status+"']").hide();
                $(".Hide[name='"+status+"']").show();
            });
            $("#Hide").click(function(){
                status = $(this).attr("name");
                $(".Div[name='"+status+"']").hide("slow");
                $(".Hide[name='"+status+"']").hide();
                $(".Show[name='"+status+"']").show();
            });
        });
    </script>


 

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

<div class="form-group">
        <label class="radio-inline"><input type="radio" name='selecttype'  value='1'>Class 1</label>
        <label class="radio-inline"><input type="radio" name='selecttype' checked value='2'>Class 2</label>
 </div>

<div id='catalog' style='display:none' >
        Class 1 Content
</div>
 <div id='search'>
        Class 2 Content
</div>

<script>
        $(document).ready(function(){
                $("input[name='selecttype']").change(function () {
                        if ($("input[name='selecttype']:checked").val() =='1') {
                                $('#catalog').show();
                                $('#search').hide();
                        } else {
                                $('#catalog').hide();
                                $('#search').show();
                        }
                });
        });
</script>
文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

<script>
        $(document).ready(function(){
            $('[data-toggle="popover"]').popover();
            $("#Show").click(function(){
                $("#Div").show("slow");
                $("#Show").hide();
                $("#Hide").show();
            });
            $("#Hide").click(function(){
                $("#Div").hide("slow");
                $("#Hide").hide();
                $("#Show").show();
            });
        });
</script>

 

<button type="button" class="btn btn-default" id="Show">瀏覽</button>
<button type="button" class="btn btn-default" id="Hide" style="display:none;">隱藏</button>
 

<div id="advisoryInfDiv" style="display:none;"><br/>
     <span>內容</span>
</div>

文章標籤

kkkelu1008 發表在 痞客邦 留言(0) 人氣()

«12 3