How To Increase/Decrease Amount Of Results

I’ve done all the functionality that I need to, however I’d like the user to be able to choose how many results they get, by clicking the + or - buttons.

This should come from:

var amountofresults = $("#output").val();
var urlpart5 = amountofresults;

If I change var urlpart5 = amountofresults to var urlpart5 = 10 then I get 10 results - so the problem is with the first line of the code above - I think.

Anyone any idea?

Thanks
James

ps excuse the styling - next job!

  1. You should include the whole code or link to the whole code (right now I have no idea what “#output” is).
  2. You should use camelCase (amountOfResults, urlPart) - it is js convention and it is more readable.

Doh! Included my Codepen link.

Looks like these lines:

  var searchinput = $("#search").val();
  var amountofresults = $("#output").val();

never get called.
And looks like this line:

amountofresults = $("#output").val();

is supposed to get value from div with id="output". It wont :slight_smile:

You should be getting value from input field with id="amount" and assigning it to urlpart5, like this:

var urlpart5 = $("#amount").val();

and add a default value (say 10) to the input field.

<input id="amount" placeholder="Amount of results" value="10"></input>