0

i am new in js and this could looks very easy for some you.

I need to get an input number and append it to a detination url ..?idpersona= Here i am ok.

Next step (now i do not know how to proceed), when then input is null, i nedd to add a specific fixed numer like ?idpersona=1

Here is the code, can you help me? Thanks

<script type="text/javascript">
function goToPage() {
var page = document.getElementById('page').value;
window.location = "https://www.pintalia.mx/PP.php?idpersona=" + page;
}
</script>
<input type="text" id="page" />
<input type="submit" value="INVIA" onclick="goToPage();" />

1 Answers1

0

first you check if the value exists else then you put a default value in there.

https://jsfiddle.net/zwLj0amu/

Davi DeBarros
  • 368
  • 1
  • 9