Why is it that when I click the edit button of a row, the modal unpredictably opens? Like -- few rows can be opened then the rest won't. Or when I try clicking those unopened rows, they can already be opened surprisingly. COMPLETELY UNPREDICTABLE.
Here are my codes:
Section List:
showDialogBox : boolean = false;
onToggleDialogBox(id) {
this.showDialogBox = !this.showDialogBox;
console.log(id);
}
<table class="ui very basic table">
<thead>
<tr>
<th width="35%">Name</th>
<th>Remarks</th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let section of dataSource['docs']">
<td><h4>{{section.name}}</h4></td>
<td>{{section.remark}}</td>
<td class="collapsing">
<div class="ui small basic icon buttons">
<button class="ui button"><i class="write icon" (click)="onToggleDialogBox(section._id)"></i></button>
<button class="ui button"><i class="trash icon"></i></button>
</div>
</td>
</tr>
</tbody>
</table>
<app-dialog-form *ngIf="showDialogBox" [(showDialogBox)]="showDialogBox" #form>
{{formTitle}}
<div class="action" action>
<button class="ui button basic" (click)="onToggleDialogBox()">Cancel</button>
<button class="ui button primary medium" (click)="addSection(form.formValues)">Save</button>
</div>
</app-dialog-form>
Dialog Form:
(I don't think there's no need for the HTML because I just want to know why the showing of modal is unpredictable upon clicking the edit icon/button above)
#Input() showDialogBox : boolean = true;
#Output() showDialogBoxChange = new EventEmitter<boolean>();
Related
I need to make the text input field in responsive. Currently, it matches width of other input elements, but when I decrease my screen size, the input field does not respond accordingly.
<div class="col-sm-12">
<div class="col-sm-8">
<table border="0" id="dynamic_field">
<tr>
<td><input type="text" placeholder="Digite o link da arquitetura" class="form-control"
id="txt-link[]" name="txt-link[]" value="{{old('txt-link[]')}}" style="width: 730px;">
#if($errors->has('txt-link.0'))
#foreach ($errors->get('txt-link.0') as $message)
<span class="help-block" style="margin-top:5px; margin-bottom:-5px; color:rgb(170, 56, 56)"><b>{{ $message }}</b></span>
#endforeach
#endif </td>
<td><button type="button" name="add" id="add"
<a class="btn btn-primary"><i class="fa fa-plus"></i>
</a></button></td>
</tr>
</table>
</div>
</div>
You should not fixed your width. Remove style="width: 730px;"
You have to give your table width 100%. In Bootstrap 4 there is a class w-100 to do that.
<table border="0" id="dynamic_field" class="w-100">
----
</table>
I think it will solve your problem.
I have a table in which there are several rows. For instance a table with flight reservations. To delete one reservation I need to have the customer id number as well as the flight id.
Considering I have only one button to try to submit these values to my Servlet, how do I do so?
I tried hiding one button but the solution doesn't seem to work for me.
I use request.getParameter() (with 2 separate variables of course) to try to fetch both values but at the end only one is captured and the other is null. Any other ideas?
This is an example of the table I have.
flight_id customer_id
Value 1 Value 2
Form buttons :
<section class="about-info-area section-gap">
<div class="container">
<div class="row align-items-center">
<form method="post" action="/admin_reservations" id="form_reservation"></form>
<table class="table table-bordered table-striped" style="float: left;">
<caption style="text-align: center; caption-side: top"><h2>Liste des réservations</h2></caption>
<thead class="thead-dark">
<tr>
<th scope="col">N°Flight</th>
<th scope="col">N°Client</th>
<th scope="col">Flight price</th>
</tr>
</thead>
<tbody>
<% for (Reservation reservation : allReservations) { %>
<tr>
<th scope="row"><% out.println(reservation.getFlight().getFlightNum()); %></th>
<td><% out.println(reservation.getClientNum()); %></td>
<td><% out.println(reservation.getFlightPrice()); %> €</td>
<td align="center">
<input type="submit" class="btn btn-default btn-sm" name="delete_reservation_client"
form="form_reservation" onClick="window.location.reload();" hidden
value="<% out.println(reservation.getClientNum()); %>">
</input>
<button type="submit" class="btn btn-default btn-sm" name="delete_reservation_flight"
form="form_reservation" onClick="window.location.reload();"
value="<% out.println(reservation.getFlight().getFlightNum()); %>"><span
class="glyphicon glyphicon-trash"></span>
Delete
</button>
</td>
</tr>
<%}%>
</tbody>
</table>
</div>
</div>
And my Servlet :
if(request.getParameter("delete_reservation_client")!=null &&request.getParameter("delete_reservation_flight")!=null){
int delete_reservation_client = Integer.parseInt(request.getParameter("delete_reservation_client").trim());
int delete_reservation_flight = Integer.parseInt(request.getParameter("delete_reservation_flight").trim());
System.out.println("Client : " + delete_reservation_client);
System.out.println("Flight : " + delete_reservation_flight);
try {
DBUtils.deleteReservation(conn,delete_reservation_client,delete_reservation_flight);
} catch (SQLException e) {
e.printStackTrace();
}
}
Thanks in advance for any help.
Fares
Instead of button use <a> tag and attached both value which you want to delete . i.e :
<td align="center">
<a href="/admin_reservations?delete_reservation_client=<% out.println(reservation.getClientNum()); %>&delete_reservation_flight=<% out.println(reservation.getFlight().getFlightNum()); %>">
<span class="glyphicon glyphicon-trash"></span>
Delete
</a>
And in Servlet get these values in doGet method by writing i.e request.getParameter("delete_reservation_client") and request.getParameter("delete_reservation_flight")
I'm having a table in an MVC view like this:
#model FoodCalculator.Models.MealViewModel
#{
ViewBag.Title = "Show Meals";
}
<h2>Meals</h2>
<table class="table table-striped table-hover mealDetailsTable">
<thead>
<tr>
<th>
No
</th>
<th>
Meal name
</th>
<th>
Meal type name
</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.Meals)
{
<tr id="tableRowClick" data-toggle="modal" data-id="#item.Value" data-target="#mealModal">
<td>
#Html.DisplayFor(modelItem => item.Value.MealID)
</td>
<td>
#Html.DisplayFor(modelItem => item.Value.MealName)
</td>
<td>
#Html.DisplayFor(modelItem => item.Value.MealType.MealTypeName)
</td>
<td>
<button class="btn btn-primary" data-toggle="modal" data-target="#mealModal">Details</button>
}
</tbody>
</table>
And on a row click popup shows up :
#model FoodCalculator.Models.MealViewModel
<div class="modal fade" id="mealDetails" style="display: none; border: 5px solid black; padding: 10px;" role="dialog" aria-labelledby="CmapModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Meal details</h4>
</div>
<div class="modal-body">
<input type="text" id="mealID" name="mealDetail" style="display: none;" />
#if (Model != null)
{
<h3> Meal id : #Model.SelectedMealID</h3>
#Html.Action("ShowMealDetails", "Home", new { mealID = Model.SelectedMealID })
}
Close
Save changes
This is all enabled by the javascript :
$('.mealDetailsTable').find('tr[data-id]').on('click', function () {
$('#mealDetails').modal('show');
var getIdFromRow = $(event.target).closest('tr').data('id');
$("#mealID").val(getIdFromRow);
});
And what I'm trying to do is passing viewmodel with currently clicked row data to a popup, so I could perform further actions.
Please help!!!!
Your code has issues. You are trying to generate and create a popup HTML for each of the table rows. But the id of 'data-target' attribute remains the same i.e "#mealModal". What this means is, your popup would be binded by default to the first row of the table. You need to dynamically generate and assign an if to the data-target attribute.
View.cshtml
#model FoodCalculator.Models.MealViewModel
#{
ViewBag.Title = "Show Meals";
var modelPopupId = "#mealModal" + item.Value.MealID; // Considering MealID is unique
var modelPopupReferenceId = "#"+ modelPopupId;
}
// Inside <tbody> element
#foreach (var item in Model.Meals)
{
<tr id="tableRowClick" data-toggle="modal" data-id="#item.Value" data-target="#modelPopupReferenceId">
// All other html elements
}
Popup
div class="modal fade" id="#modelPopupId" style="display: none; border: 5px solid black; padding: 10px;" role="dialog" aria-labelledby="CmapModalLabel" aria-hidden="true">
I have two tables for my inventory first is the Item List then the Item Info
I bind the Item List to a HTML Table the add a button for each row the purpose of the button is to show the Item Info or table via modal
I have already done the table and modal design but i cant get or pass the Item ID for my Item List to my modal
can anyone help me i'm kind a new in HTML (noob hir :3)
<thead>
<tr>
<th class="text-center">Item ID</th>
<th class="text-center">Particular</th>
</tr>
</thead>
<tbody class="searchable">
<% List<Inventory.MODEL.adminView>x = new List
<Inventory.MODEL.adminView>(); Inventory.BAL.ItemBAL z = new Inventory.BAL.ItemBAL(); x = z.getAdminView().ToList(); foreach (var item in x) {%>
<tr>
<td>
<%=i tem.ID %>
</td>
<td>
<%=i tem.Particulars %>
</td>
<%}%>
<td class="text-center">
<span class='glyphicon glyphicon-info-sign'></span>
</td>
</tr>
<%} %>
</tbody>
</table>
</div>
</div>
<div id="Modal" class="modal fade">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Item Inventory</h4>
</div>
<div class="modal-body">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">Item ID</th>
<th class="text-center">Total Quantity</th>
</tr>
</thead>
<tbody>
<% iteminvents(); %>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
that's my code, anyone can advice or can help me ?
Pass this in myFunction() as argument , As myFunction(this)
and inside function you can get ItemId as below. I have used jquery here.
function myFunction(sender)
{
var CurrentRow=$(sender).closest("tr");
var ItemId=$("td:eq(0)",$(CurrentRow)).html(); // Can Trim also if needed
}
I'm trying to show a form inside a fancybox but i can't get it to show something.
I dont get how this fancybox works.
My code looks like this:
Show Fancybox
<div id="divForm" >
<form action="code_eingabe.php" method="post">
<table >
<tr>
<td colspan="2"><h1>E575 - Gewinnspiel</h1></td>
</tr>
<tr>
<td colspan="2"><?php if(isset($text)){echo $text;} ?></td>
</tr>
<tr>
<td><input type="text" name="code"/></td>
<td><input type="submit" name="submit" value="submit!"/></td>
</tr>
</table>
</form>
</div>
You have to wrap your content with a div that has display: none
<div id="divForm" style="display: none">
<-- put your content here -->
</div>
EDIT
to pop up : see this sample of a popped up fancybox content when register :
$("#Register").click(function() {
if($(this).is(':checked')) {
alert("This is a fancybox! Register here.")
$('#CheckoutOptions').fancybox('');
}
})