I have 15 questions, every question must be answered. You can answer with Radio Buttons. Now I want to store every clicked radio button in a Database. I hope someone can help, I do not how this works. If someone hast a website for me, feel free to post it, I'll try it on my own. Here is the code. I have no idea if this is somehow right. Thank you in advance. Radio Buttons are stored this way and then the JS function:
`
<input type="radio" id="Q15one" name="valuation15" value="one">
<label for="one"> 1</label>
<input type="radio" id="Q15two" name="valuation15" value="two">
<label for="two">2</label>
<input type="radio" id="Q15three" name="valuation15" value="three">
<label for="three">3</label>
<input type="radio" id="Q15four" name="valuation15" value="four">
<label for="four">4</label>
<input type="radio" id="Q15five" name="valuation15" value="five">
<label for="five">5</label>
alert('Please answer every question.');
else {
uservalues=[2,3,4,5]
safevalues(2,uservalues)
location.href='page3circle.html';
}
}
function safevalues(values){
var db = openDatabase('AIdb.db', '1.0', 'AI within medicine', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE survey IF NOT EXISTS (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, question1 TEXT, question2 TEXT, question3 TEXT,question4 TEXT,question5 TEXT,question6 TEXT,question7 TEXT,question8 TEXT,question9 TEXT,question10 TEXT,question11 TEXT,question12 TEXT,question13 TEXT,question14 TEXT,question15 TEXT, timestamp TIMESTAMP)');
if (radioGroup.getCheckedRadioButtonId()!=0){
tx.executeSql('INSERT INTO survey (question1, timestamp) VALUES (?, ?)', [radioGroup.getCheckedRadioButtonId()], new Date());
}
if (page==2) {
tx.executeSql('INSERT INTO survey (question1,question2, question3, question4, timestamp) VALUES (?, ?,?,?)', [radioGroup.getCheckedRadioButtonId(), radioGroup.getCheckedRadioButtonId(),radioGroup.getCheckedRadioButtonId(),radioGroup.getCheckedRadioButtonId(),new Date()]);
}
else{}
}
);`