2014-01-16 49 views
0

顯示模式我有如下表:插入數據到MySQL,並點擊笨

http://i42.tinypic.com/sovfab.png

我需要插入所有字段到新表在MySQL時,我點擊「加號」按鈕。在ADITION我需要證明這個模式:

http://i39.tinypic.com/mrd63k.png

在簡歷,我需要插入數據並顯示在相同的點擊模式。

我使用MVC與codeigniter。

我可以插入數據並顯示模態,如果我獨立完成。

我使用的控制器和所有參數插入使用的網址:

  • 插入數據。 實施例:本地主機/ index.php的/控制器參數1 &參數2 &參數3

  • 要顯示模態:

我打電話與JavaScript函數的視圖與onclick="test()"和功能有

function test(){ $('#myModal').modal('show'); }

。或者更簡單地說,我可以使用

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

+0

你面臨的問題是什麼? – hubert

回答

0

我不知道我理解你的問題。 我想你應該嘗試一個AJAX調用

$.post("/Index.php/Controller?Parameter1&Parameter2&Parameter3/", function(data) { 
    $('#myModal').modal('show'); 
}); 
+0

你好!感謝它的工作! – user3200400

0

嘗試使用jQuery的,如果你喜歡,它更容易和簡單

$(".plus").on("click",function(e){ 
    var postData ={}; 
    var tr = $(this).closest('tr'); 
    var td = tr.find('td'); 
    td.each(function(i,v){ 
     if(i< td.length-1){ 
      var key = $("#tab").find("th").eq(i).html(); 
      postData[key]=$(this).html(); 
     } 
    }); 
//Now the parameters are ready send the ajax request 
$.post("your_url", postData) 
    .done(function(data) { 
    $('#myModal').modal('show'); 
    }); 
}); 
0

我假設有你使用的形式,得到領域,用途:

// This product objet to use in ajax 
    var myData = $('#ID_FORM').serializeArray();   

    // This send to you page using POST 
    $.ajax({ 
     url: 'test.php', 
     data : myData, 
     type: "post" 
    }); 

    // Now, i recomend to use http://bootboxjs.com/ 
    // See docs, using this, look 
    // Put data-attribute message in "A" to get it to use in modal box 
    // use data-message 
    // This plugin, need use bootstrap, is so easy 

    $('a').on('click', function(){ 
     var msg = $(this).data('message'); 
     bootbox.alert(msg); 
    }); 

我已經幫助