Page 1 sur 1

Modifier un film via modal

Posté : 06 nov. 2021, 21:45
par Daniel Prudent
Bonjour j"ai besoin d'aide svp. Quand je clique sur modifier film. je veux faire en sorte de pouvoir modifier les donner de mon film

<!-- Modal -->
<div class="modal fade" id="staticBackdrop1" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel1">Modifier film</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>

<form class="row g-3 needs-validation"action="submit" novalidate method="POST" id="form">
<div class="modal-body">
<textarea class="form-control" id="titre1"></textarea>
<textarea class="form-control" id="numero1"></textarea>
<textarea class="form-control" id="annee1"></textarea>
<textarea class="form-control" id="duree1"></textarea>
<textarea class="form-control" id="categorie1"></textarea>
<textarea class="form-control" id="directeur1"></textarea>
<textarea class="form-control" id="acteur1"></textarea>
<textarea class="form-control" id="description1"></textarea>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="submit" onclick="modifierFilm1()" class="btn btn-primary">Modifier</button>


function addFilm() {

let id = document.getElementById('numero').value;
let title = document.getElementById('titre').value;
let year = document.getElementById('annee').value;
let runtime = document.getElementById('duree').value;
let genres = document.getElementById('categorie').value;
let director = document.getElementById('directeur').value;
let actors = document.getElementById('acteur').value;
let plot = document.getElementById('description').value;
// let posterUrl = document.getElementById('photo').value;

let unFilm = { "id": id, "title": title, "year": year, "runtime": runtime, "genres": genres, "director": director, "actors": actors, "plot": plot };


function addFilmAndRefreshPage() {

let enleverFilm = (leFilm) => {
let racine = leFilm;

$("#form").submit(function (event) {
event.preventDefault(); //prevent default action
var post_url = $(this).attr("submit"); //get form action url
var form_data = $(this).serialize(id, title, year, runtime, genres, director, actors, plot); //Encode form elements for submission

$.post(post_url, form_data, function (response) {

function modifierFilm(index) {
document.getElementById('numero1').value = myArray[index].id;
document.getElementById('titre1').value = myArray[index].title;
document.getElementById('annee1').value = myArray[index].year;
document.getElementById('duree1').value = myArray[index].runtime;
document.getElementById('categorie1').value = myArray[index].genres;
document.getElementById('directeur1').value = myArray[index].director;
document.getElementById('acteur1').value = myArray[index].actors;
document.getElementById('description1').value = myArray[index].plot;

function modifierFilm1() {
var id = document.getElementById('numero1').value

for (var i = 0; i < id.length; i++) {
var unFilm = document.getElementById("numero1").value;
var unFilm = document.getElementById('title1').value
var unFilm = document.getElementById('annee1').value
var unFilm = document.getElementById('duree1').value
var unFilm = document.getElementById('categorie1').value
var unFilm = document.getElementById('directeur1').value
var unFilm = document.getElementById('acteur1').value
var unFilm = document.getElementById('description1').value
//document.getElementById("title").innerHTML = title;


Re: Modifier un film via modal

Posté : 14 juil. 2023, 10:41
par instructoronto
It is the only thing you need to include in your HTML. The class names (edit,show,deleteEnr) are critical; they will assist you in executing JS code; do not skip them.

Re: Modifier un film via modal

Posté : 07 nov. 2023, 09:45
par Maridns
That's all that you have to put in your HTML. Do not omit the class names (edit,show,deleteEnr); they are essential and will help you run JS code.
free games