0

I'm doing a project and I don't understand the front end well. I have this html page:

<form class="form-group" action="/create" method="post" enctype="multipart/form-data">

            <div class="title">
                <h1>Cadastre seu produto</h1>
            </div>

            <div class="single-input">
                <input class="form-control" placeholder="nome do produto" type="text" id="nome_produto" name="nome_produto">
            </div>

            <div class="single-input">
                <input class="form-control" placeholder="quantidade em estoque" type="number" id="quantidade" name="quantidade">
            </div>

            <div class="single-input">
                <input class="form-control" placeholder="preco do produto" type="number" id="preco_produto" name="preco_produto">
            </div>
            <button onclick="loadPage()" id="button" type="submit" class="btn btn btn-danger">ENVIAR</button>
        </form>       

I want that when I click on the SUBMIT button, I am redirected to another page, I want to do this using Javascript.

I tried to do this:

<script type="text/javascript">
function loadPage(){
    window.location("http://localhost:8080/list")
}

but it's not working, every time I click on the button I'm redirected to a blank page Any solution ?

2
  • What is the blank page's URL? Commented Jan 7, 2023 at 12:05
  • <button type='submit' => <button type='button' Commented Jan 7, 2023 at 14:25

1 Answer 1

2

Window.location is a property not a function. So it should be

window.location = "http://localhost:8080/list";

More details here: https://developer.mozilla.org/en-US/docs/Web/API/Window/location

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.