0

I'm trying to make a website with a sort of survey where the user picks one of 2 buttons with different text values and the website saves what value he picked and reloads the website giving the user 2 new values on the buttons. I already made the system for rolling new button values and reloading when one of them is picked but I cant figure out how to save data.

This is the current code I have:

function b1() {
  data = document.getElementById("b1").innerHTML;
  alert(data);
  location.reload();
}

This function is called when one of the buttons is pressed (there is another one for the other button) and the data variable is what value is on the button. Instead of alerting the data variable I want to be able to add 1 to a variable in a database which counts how many times this value was picked.

I already tried using the google sheets api but it did not work and just stopped the code from working. I tried adding a .txt file and use js to edit it but since js is ran client side it cant edit server side files.

1
  • Obviously you are missing allot of basic understanding of how the web works. I suggest you read and learn more about client and server programming, and how they interact, before venturing on developing a new web site. Commented Nov 29, 2022 at 8:33

1 Answer 1

1

You can use google forms for that. Usually if you want a custom solution you would need PHP. Using external software like with an API you can get an easy solution without too much effort.

At the end of google forms when you have made your form, you have the option to share, and there you should click the "<>" tab to copy the iframe into your HTML.

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

1 Comment

PHP is one option, of course. Any server side programming framework will work.

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.