How to Open Bootstrap Modal Box after few seconds

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: views/courses-details.php

Line Number: 76

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 76
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/courses-details.php

Line Number: 76

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 76
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

Training Mode Regular Fastrack Crash
Classroom | Online

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: views/courses-details.php

Line Number: 116

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 116
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/courses-details.php

Line Number: 116

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 116
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

Course Description :
Solution :  Here are some steps to load modal box of bootstrap after few seconds , there is need sometime to load modal box in website after few seconds, this is common requirement for websiter such as pop of enquiry form, offer pop up etc. , So by following these steps we can achieve :

Step 1 : Add Modal Box of bootstrap
<!-- The Modal -->
<div class="modal fade" id="loadModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header customclose">
<h2 style="float:left; color:#fff;">Quick Enquiry</h2>
<button type="button" class="close " data-dismiss="modal" >&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body " style="background:#eee;">

<div class="row">
<div class="col-lg-12">
<form name="contact_form" class="contact-form frmp" action="" method="post">
<div class="form-group">
<input type="name" class="form-control" id="name" name="name" placeholder="Enter Your Name">

</div>
<div class="form-group">
<input type="text" class="form-control" id="enteremail" name="phone" placeholder="Enter Your Phone">

</div>
<div class="form-group">
<input type="email" class="form-control" id="enteremail" name="email" placeholder="Enter Your Email">

</div>
<div class="form-group">
<select class="form-control" id="sel1" name="country">
<option value="">Country You Wish to Migrate to</option>
<option value="Canada">Canada</option>
<option value="Australia">Australia</option>
<option value="USA">Germany </option>
<option value="UK">Hong Kong</option>
</select>

</div>

<div class="form-group">
<textarea class="form-control" id="exampleFormControlTextarea1" placeholder="Your Message..." rows="2" name="message"></textarea>
</div>

<button type="submit" name="submit" class="btn btn-primary massage-btn clrbtn">Send Your Message</button>

</form>
</div>
</div>
</div>

</div>
</div>
</div>


Step2 : Add this script before closing body tag

<script type="text/javascript">
$(window).on('load',function(){
setTimeout(function(){
$('#loadModal').modal('show');
}, 3000);

});
</script>

Complete Code :

<!DOCTYPE html>
<html lang="en">
<head>
<title>Modal Box Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
 
<!-- The Modal -->
<div class="modal fade" id="loadModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header customclose">
<h2 style="float:left; color:#fff;">Quick Enquiry</h2>
<button type="button" class="close " data-dismiss="modal" >&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body " style="background:#eee;">

<div class="row">
<div class="col-lg-12">
<form name="contact_form" class="contact-form frmp" action="" method="post">
<input type="hidden" name="_a2a2a_" value="4">
<div class="form-group">
<input type="name" class="form-control" id="name" name="name" placeholder="Enter Your Name">

</div>
<div class="form-group">
<input type="text" class="form-control" id="enteremail" name="phone" placeholder="Enter Your Phone">

</div>
<div class="form-group">
<input type="email" class="form-control" id="enteremail" name="email" placeholder="Enter Your Email">

</div>
<div class="form-group">
<select class="form-control" id="sel1" name="country">
<option value="">Country You Wish to Migrate to</option>
<option value="Canada">Canada</option>
<option value="Australia">Australia</option>
<option value="USA">Germany </option>
<option value="UK">Hong Kong</option>
</select>

</div>

<div class="form-group">
<textarea class="form-control" id="exampleFormControlTextarea1" placeholder="Your Message..." rows="2" name="message"></textarea>
</div>

<button type="submit" name="submit" class="btn btn-primary massage-btn clrbtn">Send Your Message</button>

</form>
</div>
</div>
</div>

</div>
</div>
</div>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>


<script type="text/javascript">
$(window).on('load',function(){
setTimeout(function(){
$('#loadModal').modal('show');
}, 3000);

});
</script>

</body>
</html>


A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: views/courses-details.php

Line Number: 422

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 422
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/courses-details.php

Line Number: 422

Backtrace:

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/views/courses-details.php
Line: 422
Function: _error_handler

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/application/controllers/Welcome.php
Line: 653
Function: view

File: /home/hrdv7o2ounf4/public_html/institute-websites/webdevelopmentinstitute.com/index.php
Line: 315
Function: require_once

Request a Demo

Whatsapp