Issue with creating new html/css elements inside jinja loops (Django) - html

I am trying to create new html/css elements inside a jinja loop while within a form , where i am filling data that I brought from a django view. All the normal browser side stuff like pop-up on button clicks is good. But only the last button successfully makes a GET request whereas every button must do. This is my form here :
<form method="GET" action="{% url 'search_results' %}">
{% csrf_token %}
{% for name,quali,field,address,pro,c in data %}
<div class="ser_tile">
<img src={{pro}} id="user_dr" >
<button class="btn_tile" id="btn1" data-toggle="modal" data-target="#{{c}}">Visit Page</button>
<button class="btn_tile" id="btn1" data-toggle="modal" data-target="#b{{c}}">Book Appointment</button><br/><br/>
<span >
Name: {{name}}
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span><br/>
Degree: {{quali}}<br/>
Specialist: {{field}}<br/>
Hospital: Pradyumna Bal Memorial Hospital<br/>
Address: {{address}}
</span>
</div><br>
<div class="modal fade" id="{{c}}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Profile</h4>
</div>
<div class="modal-body">
<center>
<div class="modal_cov"></div>
<img class="modal_ico" src={{pro}}><br/><b>{{name}}</b><br/>Pradyumna Bal Memorial Hospital
<hr/>
</center>
<div>
<table>
<tr>
<td class="td"><b> Specialist:</b></td>
<td>
{{field}}
</td>
</tr>
<tr>
<td><b> Ratting:</b></td>
<td>
3
</td>
</tr>
<tr>
<td><b>Available On:</b></td>
<td>
Monday(10:30AM : 5:00PM), Thursday(10:30AM : 1:00PM) , Saturday(10:30AM : 1:00PM)
</td>
</tr>
<tr>
<td><b>Minimum Chagre:</b></td>
<td>
Rs:500/-
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer qq{{c}}">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button class="btn_tile" data-toggle="modal" data-target="#b{{c}}" data-dismiss="modal">Book Appointment</button>
</div>
</div>
</div>
</div>
<script>
$(".btn_tile").click(function(event){
event.preventDefault();
});
</script>
<div class="modal fade" id="b{{c}}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Profile</h4>
</div>
<div class="modal-body">
<center>
<div class="modal_cov"></div>
<img class="modal_ico" src={{pro}}><br/><b>{{name}}</b><br/>Pradyumna Bal Memorial Hospital
<hr/>
</center>
<div>
<table>
<tr>
<td class="td"><b> Date:</b></td>
<td>
<input name="date" class="td_in" type="date">
</td>
</tr>
<tr>
<td ><b> Time:</b></td>
<td>
<input name="time" class="td_in" type="time">
</td>
<td>
<b>Avilable times: </b>
</td>
<td>
1:00PM, 3:00PM
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" name="book" value="confirm" class="btn_tile" >Confirm Booking</button>
</div>
</div>
</div>
</div>
<hr/>
{% endfor %}
</form>
This particular button (Confirm Booking) has to generate a GET request but it fails to. The array request.GET() returns None.
here is a screenshot of the popup

You could try inserting the button into a form as below....
<form method="get" action="<YOUR DESIRED ACTION>">
<button type="submit" name="book" value="confirm" class="btn_tile" >Confirm Booking</button>
</form>
hope it helps...

Related

New to Modals and can not get modal to appear when button is selected

On this screen, a user can see all the questions from the database. Features include the ability to move the order of the question, delete, or add a question. When the user selects add I want a modal to appear. The following code will not work and is nonresponsive when I hit add.
<div class="modal" id="addQuestion" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4>DemoTitle</h4>
</div>
<div class="modal-body">
<p>put a lot of stuff here</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal">close</button>
</div>
</div>
</div>
<div class="admin-center">
<table id="main-table" class="table table-striped table-bordered">
<thead>
<tr>
<th class="select-all">
<input type="checkbox" class="hide" id="select-all-checkbox" />
<h3><label style="font-weight:normal;" for="select-all-checkbox">Select</label></h3>
</th>
<th><h4 class="nobr"><label>Position</label></h4></th>
<th><h4 style="text-align:left;" class="nobr"><label>Question</label></h4></th>
</tr>
</thead>
<tbody>
#foreach (var question in Model.allQuestions)
{
<tr>
<td><input type="checkbox" name="select" value="#question.position" /></td>
<td>#question.position</td>
<td style="text-align:left;">#question.question</td>
</tr>
}
</tbody>
</table>
<br />
<br />
<div class="admin-center">
<button id="btnUp" class="btn btn-lg btn-primary">Move Up</button>
<button id="btnDown" class="btn btn-lg btn-primary">Move Down</button>
</div>
<br />
<div class="admin-center">
<a class="btn btn-lg btn-primary" data-toggle="#addQuestion">Add Questions</a>
<a class="btn btn-lg btn-primary">Delete Question</a>
</div>
#addQuestion Should be the value of data-target attribute. Also data-toggle attribute should have a value of modal
This should work
<a class="btn btn-lg btn-primary" data-toggle="modal"
data-target="#addQuestion">Add Questions</a>
Assuming you have properly loaded the needed JavaScript files(bootstrap) and you do not have any other script errors in the page which is preventing the script needed for modal dialog to work properly.(You can verify this in console tab of your F12 dev tools)
Here is a working JSFiddle for you to refer http://jsbin.com/neyixukuzu/edit?html,console,output
please add two attribute to your a link
data-toggle="modal" data-target="#addQuestion"

How to extract value from an html table with asp.net?

I have a table like this:
<tbody>
#foreach (Class cs in Model.MyClass)
{
statut = (cs.statut == "yes") ? "enable": "disable";
<tr class="#(cs.statut == "yes" ? "success" : "danger") ">
<td rowspan="2" >#cs.title</td>
<td>#cs.att[0]</td>
<td>#cs.att2[0]</td>
<td rowspan="2">#cs.att3</td>
<td rowspan="2"><button class="btn btn-primary" data-toggle="modal" data-target="#myModal">#(cs.statut == "yes" ? "Désactiver" : "Activer") </button></td>
<td rowspan="2"><button class="btn btn-primary" data-toggle="modal" data-target="#modify">Modifier </button></td>
</tr>
<tr class="#(cs.statut == "yes" ? "success" : "danger") ">
<td>#cs.att[1]</td>
<td>#cs.att2[1]</td>
</tr>
<div class="modal fade bs-example-modal-md" id="modifier" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Modify #cd.title</h4>
</div>
<div class="modal-body">
<form class="form">
<div class="">
<label for="groupe" class="col-sm-3 control-label">Groupe</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="groupe" value="#cs.title">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Confirm</button>
</div>
</div>
</div>
</div>
}
</tbody>
I want to do some modification, but I don't know how can I get the actual value of the row?
When I tested modify button, I get the same value for all those bottons and it's for the first row.
Thanks in advance,

Angular Datepicker displaying twice in bootstrap modal

I'm new to Angular JS. I was working with Angular JS calendar and am trying to display the angular Datepicker inside Bootstrap modal window. However the Datepicker is displayed twice as shown in the image below.
Here's my modal html code.
<div class="modal-header">
<h3 class="modal-title">{{ vm.event.event.title }}</h3>
</div>
<div class="modal-body" ng-repeat="event in vm.event track by $index">
<h3 class="post-subtitle">
{{event.type}}
</h3>
<table class="table table-bordered">
<thead>
<th>Starts on</th>
<th>Ends on</th>
</thead>
<tbody>
<td>
<p class="input-group" style="max-width: 250px">
<input
type="text"
class="form-control"
readonly
uib-datepicker-popup="dd MMMM yyyy"
ng-model="event.startsAt"
is-open="event.startOpen"
close-text="Close" >
<span class="input-group-btn">
<button
type="button"
class="btn btn-default"
ng-click="vm.object.toggle($event, 'startOpen', event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<uib-timepicker
ng-model="event.startsAt"
hour-step="1"
minute-step="15"
show-meridian="true">
</uib-timepicker>
</td>
<td>
<p class="input-group" style="max-width: 250px">
<input
type="text"
class="form-control"
readonly
uib-datepicker-popup="dd MMMM yyyy"
ng-model="event.endsAt"
is-open="event.endOpen"
close-text="Close">
<span class="input-group-btn">
<button
type="button"
class="btn btn-default"
ng-click="vm.object.toggle($event, 'endOpen', event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<uib-timepicker
ng-model="event.endsAt"
hour-step="1"
minute-step="15"
show-meridian="true">
</uib-timepicker>
</td>
</tbody>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="$close()">OK</button>
</div>

Bootstrap Modal not greying out 100%

Trying to get a Bootstrap Modal to grey out the background when clicked. It works great but the left sidebar does not grey out. Any idea of why?
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li>Customers</li>
<li>Company</li>
</ul>
</div>
</div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">
New company
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Add company</h4>
</div>
<div class="modal-body">
{% from "_formhelpers.html" import render_field %}
<form action="/company/create" method="POST">
<div class="form-group">
{{ render_field(form.name, class="form-control") }}
</div>
{{ error }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<button type="button" class="btn btn-success btn-md" data-toggle="modal" data-target="#myNewModal">
New customer
</button>
<!-- Modal -->
<div class="modal fade" id="myNewModal" tabindex="-1" role="dialog" aria-labelledby="myNewModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Add customer</h4>
</div>
<div class="modal-body">
{% from "_formhelpers.html" import render_field %}
<form action="/customer/create" method="POST">
<div class="form-group">
{{ render_field(forms.name, class="form-control") }}
</div>
<div class="form-group">
{{ render_field(forms.email, class="form-control") }}
</div>
<div class="form-group">
{{ render_field(forms.summary, class="form-control") }}
</div>
<div class="form-group">
{{ render_field(forms.purpose, cols="100", rows="10", class="form-control") }}
</div>
<div class="form-group">
{{ render_field(forms.company, class="form-control") }}
</div>
{{ error }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<h2 class="sub-header">Customers</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>Company</th>
</tr>
</thead>
{% for customer in customers %}
<tbody>
<tr>
<td>{{ customer.id }}</td>
<td>{{ customer.name }}</td>
<td>{{ customer.company.name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
It's a Flask application on local. Let me know if I can provide more information.
Thanks

How to make two bootstrap modal forms submit independently?

I have two bootstrap modal forms on the same html document.
I want to get these forms to work independently, however, form 1 does not
submit and form2 submits the data entered in both forms.
How do I get these forms to work independently without interfering with the actions
of one another?
Here is the HTML:
<!------------------------form1----------------------------------->
<div class="modal fade" id="register" tabindex="-1" role="dialog" aria-labelledby="orderLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="panel panel-primary">
<div class="panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="panel-title" id="registerLabel"><span class="glyphicon glyphicon-info-sign"></span> Register</h4>
</div>
<form id="form1" action="register.php " method="post" accept-charset="utf-8">
<div class="modal-body" style="padding: 5px;">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12" style="padding-bottom: 10px;">
<input class="form-control" name="name" placeholder="Name" type="text" required />
</div>
</div>
<div class="panel-footer" style="margin-bottom:-14px;" data-target="form1" >
<input type="submit" class="btn btn-success" value="Send"/>
<!--<span class="glyphicon glyphicon-ok"></span>-->
<input type="reset" class="btn btn-danger" value="Clear" />
<!--<span class="glyphicon glyphicon-remove"></span>-->
<button style="float: right;" type="button" class="btn btn-default btn-close" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!------------------------form2----------------------------------->
<div class="modal fade" id="buy" tabindex="-1" role="dialog" aria-labelledby="buyLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="panel panel-primary">
<div class="panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="panel-title" id="buyLabel"><span class="glyphicon glyphicon-info-sign"></span> Buy</h4>
</div>
<form id="form2" action="buy.php " method="post" accept-charset="utf-8">
<div class="modal-body" style="padding: 5px;">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12" style="padding-bottom: 10px;">
<input class="form-control" item="item" placeholder="Name" type="text" required />
</div>
</div>
<div class="panel-footer" style="margin-bottom:-14px;" data-target="form1" >
<input type="submit" class="btn btn-success" value="Send"/>
<!--<span class="glyphicon glyphicon-ok"></span>-->
<input type="reset" class="btn btn-danger" value="Clear" />
<!--<span class="glyphicon glyphicon-remove"></span>-->
<button style="float: right;" type="button" class="btn btn-default btn-close" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
I can't see the forms ending somewhere.
Please close form before starting another so that it will be independent.