skip to Main Content

I keep getting the error: Uncaught SyntaxError: missing ) after argument list (at bestellen:60:105)

this is my html:

  <div class="gerechten">
    {% for gerecht in gerechten %}
    
    <div class="Gerechtdiv">
      <img src={{gerecht.url}} class="gerechtimg">
      <h3 class="GerechtTitel">{{gerecht.gerecht}}</h3>
      <p class ="GerechtBeschrijving">{{gerecht.beschrijving}}</p>
      <div class ="BottomGerechtDiv">
        <p style="font-size: 17px;"><b>€{{gerecht.prijs}}</b></p>
        <p>{{gerecht.sterren}}&#9733</p>
      </div>
      <button class="button" onclick="addItemToCart({{gerecht.gerecht}}, {{gerecht.prijs}})" style="cursor: pointer"><span>Voeg toe aan winkelwagen</span> </button>
    </div>
    
    {% endfor %}
  </div>

the line the error is referring to is the button line.

i tried clearing the onclick function, then it works, but when i put in the function it gives me an error again

2

Answers


  1. It could be that {gerecht.prijs} is missing one pair of {}. So you should write:

    <button class="button" onclick="addItemToCart({{gerecht.gerecht}}, {{gerecht.prijs}})" style="cursor: pointer"><span>Voeg toe aan winkelwagen</span> </button>
    
    Login or Signup to reply.
  2. The error you get is a Javascript error.

    addItemToCart({{gerecht.gerecht}}, {{gerecht.prijs}})
    

    is being evaluated and you will need to find out what the values of gerecht.gerecht and gerecht.prijs is. If your code ends up looking like

    addItemToCart(5, "a" b);
    

    which reproduces your problem:

    function addItemToCart() {} //mocking the function
    addItemToCart(5, "a" b);
    console.log(1);

    then the problem is explained. So it all boils down to your template values.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search