Skip to main content
se añadieron 38 caracteres en el cuerpo
Origen Enlace
Israel-ICM
  • 3.6k
  • 25
  • 20
  • 26

function addToTable(title, year, type, poster, id) { var table = document.getElementById("table"); table.innerHTML += <tbody> <tr> <td><a href="${poster}">${title}</a></td> <td>${id}</td> <td style="text-transform: capitalize">${type}</td> <td>${year}</td> <td><button class="btn btn-primary" onclick="moreInfo(${title})">Click Here</button></td> </tr> </tbody>; }

function moreInfo (name) { var table = document.getElementById("table"); table.innerHTML = <thead class="thead-dark"> <tr> <th scope="col">Title</th> <th scope="col">Year</th> <th scope="col">Rated</th> <th scope="col">Released</th> <th scope="col">Genre</th> <th scope="col">Director</th> <th scope="col">Writer</th> <th scope="col">Actors</th> <th scope="col">Plot</th> <th scope="col">Language</th> <th scope="col">Country</th> <th scope="col">Awards</th> <th scope="col">imdbRating</th> <th scope="col">imdbVotes</th> <th scope="col">imdbID</th> <th scope="col">Type</th> <th scope="col">BoxOffice</th> <th scope="col">Production</th> </tr> </thead>;

function addToTable(title, year, type, poster, id) {
    var table = document.getElementById("table");
    table.innerHTML += `
        <tbody> 
        <tr>
            <td><a href="${poster}">${title}</a></td>
            <td>${id}</td>
            <td style="text-transform: capitalize">${type}</td>
            <td>${year}</td>
            <td><button class="btn btn-primary" onclick="moreInfo(${title})">Click Here</button></td>
      </tr>
      </tbody>`;
}

function moreInfo (name) {
    var table = document.getElementById("table");
    table.innerHTML = `         
    <thead class="thead-dark">
    <tr>
        <th scope="col">Title</th>
        <th scope="col">Year</th>
        <th scope="col">Rated</th>
        <th scope="col">Released</th>
        <th scope="col">Genre</th>
        <th scope="col">Director</th>
        <th scope="col">Writer</th>
        <th scope="col">Actors</th>
        <th scope="col">Plot</th>
        <th scope="col">Language</th>
        <th scope="col">Country</th>
        <th scope="col">Awards</th>
        <th scope="col">imdbRating</th>
        <th scope="col">imdbVotes</th>
        <th scope="col">imdbID</th>
        <th scope="col">Type</th>
        <th scope="col">BoxOffice</th>
        <th scope="col">Production</th>
    </tr>
    </thead>`;

    fetch(`http://www.omdbapi.com/?apikey=683c6fd6&t=${name}`)
    .then(res => res.json())
    .then(data => {
      if (data.Response == "False") {
        alert(data.Error);
      }else {
            addToTable2(element.Title, element.Year, element.Rated, element.Released,
                element.Genre, element.Director, element.Writer, element.Actors, 
                element.Plot, element.Language, element.Country, element.Awards,
                element.imdbRating, element.imdbVotes, element.imdbID, element.Type,
                element.BoxOffice, element.Production, element.Poster); 
      }
    });
}

}

En el boton click herebotón click here de la funcion addToTablefunción addToTable hay un onClickonClick que llama a moreInfomoreInfo, sin embargo cuando le doy click me tira el siguiente error: Uncaught SyntaxError: missing ) after argument list.

Uncaught SyntaxError: missing ) after argument list

Evidentemente me esta faltando un parentesisparéntesis pero no puedo encontrar donde. El VSCode tampoco me encuentra ningunningún error de syntaxis... Alguien

¿Alguien sabe como solucionarlo? Gracias

Gracias desde ya.

function addToTable(title, year, type, poster, id) { var table = document.getElementById("table"); table.innerHTML += <tbody> <tr> <td><a href="${poster}">${title}</a></td> <td>${id}</td> <td style="text-transform: capitalize">${type}</td> <td>${year}</td> <td><button class="btn btn-primary" onclick="moreInfo(${title})">Click Here</button></td> </tr> </tbody>; }

function moreInfo (name) { var table = document.getElementById("table"); table.innerHTML = <thead class="thead-dark"> <tr> <th scope="col">Title</th> <th scope="col">Year</th> <th scope="col">Rated</th> <th scope="col">Released</th> <th scope="col">Genre</th> <th scope="col">Director</th> <th scope="col">Writer</th> <th scope="col">Actors</th> <th scope="col">Plot</th> <th scope="col">Language</th> <th scope="col">Country</th> <th scope="col">Awards</th> <th scope="col">imdbRating</th> <th scope="col">imdbVotes</th> <th scope="col">imdbID</th> <th scope="col">Type</th> <th scope="col">BoxOffice</th> <th scope="col">Production</th> </tr> </thead>;

fetch(`http://www.omdbapi.com/?apikey=683c6fd6&t=${name}`)
.then(res => res.json())
.then(data => {
  if (data.Response == "False") {
    alert(data.Error);
  }else {
        addToTable2(element.Title, element.Year, element.Rated, element.Released,
            element.Genre, element.Director, element.Writer, element.Actors, 
            element.Plot, element.Language, element.Country, element.Awards,
            element.imdbRating, element.imdbVotes, element.imdbID, element.Type,
            element.BoxOffice, element.Production, element.Poster); 
  }
});

}

En el boton click here de la funcion addToTable hay un onClick que llama a moreInfo, sin embargo cuando le doy click me tira el siguiente error: Uncaught SyntaxError: missing ) after argument list. Evidentemente me esta faltando un parentesis pero no puedo encontrar donde. El VSCode tampoco me encuentra ningun error de syntaxis... Alguien sabe como solucionarlo? Gracias desde ya.

function addToTable(title, year, type, poster, id) {
    var table = document.getElementById("table");
    table.innerHTML += `
        <tbody> 
        <tr>
            <td><a href="${poster}">${title}</a></td>
            <td>${id}</td>
            <td style="text-transform: capitalize">${type}</td>
            <td>${year}</td>
            <td><button class="btn btn-primary" onclick="moreInfo(${title})">Click Here</button></td>
      </tr>
      </tbody>`;
}

function moreInfo (name) {
    var table = document.getElementById("table");
    table.innerHTML = `         
    <thead class="thead-dark">
    <tr>
        <th scope="col">Title</th>
        <th scope="col">Year</th>
        <th scope="col">Rated</th>
        <th scope="col">Released</th>
        <th scope="col">Genre</th>
        <th scope="col">Director</th>
        <th scope="col">Writer</th>
        <th scope="col">Actors</th>
        <th scope="col">Plot</th>
        <th scope="col">Language</th>
        <th scope="col">Country</th>
        <th scope="col">Awards</th>
        <th scope="col">imdbRating</th>
        <th scope="col">imdbVotes</th>
        <th scope="col">imdbID</th>
        <th scope="col">Type</th>
        <th scope="col">BoxOffice</th>
        <th scope="col">Production</th>
    </tr>
    </thead>`;

    fetch(`http://www.omdbapi.com/?apikey=683c6fd6&t=${name}`)
    .then(res => res.json())
    .then(data => {
      if (data.Response == "False") {
        alert(data.Error);
      }else {
            addToTable2(element.Title, element.Year, element.Rated, element.Released,
                element.Genre, element.Director, element.Writer, element.Actors, 
                element.Plot, element.Language, element.Country, element.Awards,
                element.imdbRating, element.imdbVotes, element.imdbID, element.Type,
                element.BoxOffice, element.Production, element.Poster); 
      }
    });
}

En el botón click here de la función addToTable hay un onClick que llama a moreInfo, sin embargo cuando le doy click me tira el siguiente error:

Uncaught SyntaxError: missing ) after argument list

Evidentemente me esta faltando un paréntesis pero no puedo encontrar donde. El VSCode tampoco me encuentra ningún error de syntaxis...

¿Alguien sabe como solucionarlo?

Gracias desde ya.

Origen Enlace

"Uncaught SyntaxError: missing ) after argument list" en JS

function addToTable(title, year, type, poster, id) { var table = document.getElementById("table"); table.innerHTML += <tbody> <tr> <td><a href="${poster}">${title}</a></td> <td>${id}</td> <td style="text-transform: capitalize">${type}</td> <td>${year}</td> <td><button class="btn btn-primary" onclick="moreInfo(${title})">Click Here</button></td> </tr> </tbody>; }

function moreInfo (name) { var table = document.getElementById("table"); table.innerHTML = <thead class="thead-dark"> <tr> <th scope="col">Title</th> <th scope="col">Year</th> <th scope="col">Rated</th> <th scope="col">Released</th> <th scope="col">Genre</th> <th scope="col">Director</th> <th scope="col">Writer</th> <th scope="col">Actors</th> <th scope="col">Plot</th> <th scope="col">Language</th> <th scope="col">Country</th> <th scope="col">Awards</th> <th scope="col">imdbRating</th> <th scope="col">imdbVotes</th> <th scope="col">imdbID</th> <th scope="col">Type</th> <th scope="col">BoxOffice</th> <th scope="col">Production</th> </tr> </thead>;

fetch(`http://www.omdbapi.com/?apikey=683c6fd6&t=${name}`)
.then(res => res.json())
.then(data => {
  if (data.Response == "False") {
    alert(data.Error);
  }else {
        addToTable2(element.Title, element.Year, element.Rated, element.Released,
            element.Genre, element.Director, element.Writer, element.Actors, 
            element.Plot, element.Language, element.Country, element.Awards,
            element.imdbRating, element.imdbVotes, element.imdbID, element.Type,
            element.BoxOffice, element.Production, element.Poster); 
  }
});

}

En el boton click here de la funcion addToTable hay un onClick que llama a moreInfo, sin embargo cuando le doy click me tira el siguiente error: Uncaught SyntaxError: missing ) after argument list. Evidentemente me esta faltando un parentesis pero no puedo encontrar donde. El VSCode tampoco me encuentra ningun error de syntaxis... Alguien sabe como solucionarlo? Gracias desde ya.