多次对动态内容使用相同的模式代码

时间:2019-06-06 00:39:07

标签: javascript php html bootstrap-modal

我的HTML中有以下模式

<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalCenterTitle">-----</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ----
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">ശരി</button>
      </div>
    </div>
  </div>
</div>

我正在根据条件$resultCheck > 0使用以下php-javascript组合触发此模式

if($resultCheck > 0){
			echo '<script>
			$("#exampleModalCenter").modal("show");
			</script>';
}

我需要的

我需要对不同的条件使用相同的模式exampleModalCenter,例如$resultCheck = 0,依此类推,标题和内容会根据条件而变化。有人知道怎么做吗?

1 个答案:

答案 0 :(得分:2)

是的,可以使用。您可以根据触发模式的条件来更改标题和内容。

为此,

function setupSheet() {
var s = SpreadsheetApp.getActive().getSheetByName('ID');
var sheet_name = s.getRange("A1").getValue(); // Get the value of cell A1, used to name the new spreadsheet.
var ID = DriveApp.getFileById("XXXXXXXX").makeCopy(sheet_name, DriveApp.getFolderById("XXXXXXXX")).getId(); //Copies the specific Spreadsheet into an specific folder.
  Logger.log(ID); //Saves the ID of the new Spreadsheet into the Log.
var stringToWrite = Logger.getLog();
SpreadsheetApp.getActive().getActiveSheet().getRange("B1").setValue(stringToWrite); //Writes the ID of the sheet from the Log.
//ID.deleteSheet(ID.getSheetByName('ID')); // remove "ID" sheet which was created by default in new spreadsheet.

}

您可以对其他内容执行相同的操作。