Get value from input field and insert in URL Javascript

I have a form on wordpress, I need to get a value from a field and pass it into this script. This is what I’ve managed to do so far. The redirection works perfectly. I just need to put the value into the url as a parameter. I don’t know the basics or theories of javascript. I just google and manage to put them together. Could anyone please help me out?
Thanks!

<script>
  function getinputval()
    {
        var numpages1 = document.getElementById("numberofpages1").value;} 
document.addEventListener( 'wpcf7mailsent', function( event ) {
if (document.getElementById('selectservice').value=='Certified Translation') {location.replace('https://example.com?add-to-cart=856&quantity=+numpages1;')}
else if (document.getElementById('selectservice').value=='Business Translation') {location.replace('http://www.redirectedpage2.com')}
else { location.replace('http://www.redirectedpage3.com/') }
}, false );
</script>