2014-09-27 57 views
1

id如何才能去我的Modal進行編輯?我使用的是PHP,必須使用對話框模式來更新數據。我怎樣才能做到這一點?使用對話框模式添加和編輯數據(php mysql)

<a href="" data-toggle="modal" data-target="#myLargeModal"> 
    <?=$objResult["ID"]; ?> 
    <div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog" 
     aria-hidden="true">   
    <input type="text" class="form-control required" name="ID" id="ID" 
    minlength="5" required/> 

    <input type="text" class="form-control required" name="Name" 
    id="Name" required> 
    </div>  
+0

'我如何能實現this' ......達到什麼樣的?請在提問 – charlietfl 2014-09-27 12:40:26

回答

0
<a href="" data-toggle="modal" id="modalIdOpen" data-id="<?php echo $objResult["ID"]; ?>" data-target="#myLargeModal">Open Modal</a> 

    <div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog" 
     aria-hidden="true">   
    <input type="text" class="form-control required" name="ID" id="ID" 
    minlength="5" required/> 

    <input type="text" class="form-control required" name="Name" 
    id="Name" required> 
    </div> 

必要jQuery腳本

<script> 
$(function() { 
    $(document).on('click','#modalIdOpen',function(e){ 
     //process here you can get id using 
     $('#ID').val($(this).data('id')); //and set this id to any hidden field in modal 
    }); 
}); 
</script> 
+0

時詳細說明,但數據如何在ID和姓名檔案中獲取 – pop 2014-09-27 14:14:50

0
you can put the id in a filed value directly 
    <a href="" data-toggle="modal" data-target="#myLargeModal"> open it </a> 

    <div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog"aria-hidden="true">   
    <input type="text" name="ID" value="<?=$objResult["ID"]; ?>" /> 
    <input type="text" class="form-control required" name="Name" 
    id="Name" required> 
    </div> 
相關問題