2012-09-12 19 views
0

請幫我:點擊同樣的按鈕打開模型,然後提交表格

我有一個表單提交按鈕。現在我想打開一個模式窗口點擊這個按鈕的事件。在模式中,我需要顯示一個文本框,用於在數據庫中插入2個按鈕:取消和推送。在點擊推我希望數據插入數據庫和表格提交! 不知怎的,我無法做到這一點

<form action="post_data.php" method="post"> 
    <!-- some elements --> 
    <input type ="submit" value = "Push data">  
</form> 

我使用的自舉modal.js 但我面臨的問題是我的形式分x.php現在如果我需要打開一個仿真模型,然後我需要爲我的提交按鈕提供屬性:href =「mymodal_id」和data-toggle =「modal」。如果我這樣做,我的網頁也絕對沒有什麼:(:( 請提前幫助 任何幫助西港島線將不勝感激謝謝

+0

你必須使用JavaScript來做到這一點有很多框架,幫助您即的jQuery +引導做好 – Philipp

回答

3

使用<a>觸發您的模式:

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

然後把你的提交和取消按鈕模式中:

<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-header"> 
     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
     <h3 id="myModalLabel">Pushing to DB</h3> 
    </div> 
    <div class="modal-body"> 
     <p>You are going to push data</p> 
    </div> 
    <div class="modal-footer"> 
     <button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> 
     <button type="submit" class="btn btn-primary" value="Push data">Push data</button> 
    </div> 
</div> 
+0

由於它的工作:) :)。 – Aditi