Wrong file directory

Greeting all

I am trying to lead my HTML form to another page. This is my code:

<form id="form" method="post" action="/Online Questionnaire/index-2.html" data-netlify="true">
...

<button type="submit" value="next">
            Next
        </button>

This is my second form:

<form id="form" method="post" action="/Online Questionnaire/index-3.html" data-netlify="true">

...

<button type="submit" value="next">
            Next
        </button>

etcetera. The code works well on my computer, but it shows the last page when I have clicked the “next” button in netlify.

Hi @sanda16v
If possible can you share a repository of the site you are trying to build for me help with the dedugging.

Thanks.

Hey man, the git repo is: https://github.com/sanda16/stats-project

Hi @sanda16, thanks for sharing.
I tried to visit the repository but it seems you have either deleted the repository or the link you provided to the repository is incorrect.
Kindly confirm and let me know.

Thanks.

Hey, can you please check it again at: https://github.com/sanda16/stats-project, it was private. Now it is public.

Hi @sanda16, I am able to visit the link now.
Took a look at your forms. kindly make sure that all forms in your project have different id’s.
In HTML an id is an identifier for the element in the whole document.
So no two elements in a document can have the same id.

Also take your time and make sure each form leads to the correct form name.
The form in index.html leads to index-2.html and the form in index-2.html leads to index-3.html which is expected.
However the form in index-3.html leads to itself index-3.html.
I am assuming based on the sequence the form in index-3.html is supposed to link to index-4.html.

Also since index.html, index-2.html, index-3.html, index-4.html, index-5.html are all in the Online Questionnaire folder, you don’t need to specify the action value by using absolute path. You can specify the relative path like the example below.
So action="/Online Questionnaire/index-3.html" can be action="./index-3.html" once the files you are referencing from are relative to each other.

 <form id="form-3" method="post" action="./index-3.html" data-netlify="true">

The main issue is to resolve the form id’s by giving each of them different id’s.
For example form 1 can have the id of form-1 and form 2 can have the id of form-2 and so on.

Just make sure all forms in your project don’t have the same id.

Kindly try the suggestions above and the redeploy again.
Once it’s working well and you are satisfied, you can set your project back to private if you don’t want to keep it public.

Let me know the outcome.

Thanks.

2 Likes

It worked very well man. Thank you so much! You just made my day! All the best😁!

1 Like

@sanda16, I am so grateful to have made your day. I’m glad I was able to help resolve your problem too.
Thanks.