Is there a way that if I click on a radio button, it inserts its value to database?

<form name = "data" method = "post" action = "JSP/insert.jsp">
<p>
<font size = "4">
Rate: 1<input name="radio_rate" type="radio" value="1" onclick="return validate()"/>
2<input name="radio_rate" type="radio" value="2" onclick="return validate()"/> 
3<input name="radio_rate" type="radio" value="3" onclick="return validate()"/> 
4<input name="radio_rate" type="radio" value="4" onclick="return validate()"/>
5<input name="radio_rate" type="radio" value="5" onclick="return validate()"/>
</font>
</p>
</form>

validate() javascript just checks if the user is login or not (facebook JS SDK).

what I want to do is that upon clicking the radio button, I want to insert its value to database.

document.data.submit();

I direct the page to insert.jsp using the above JS code:
INSERT.jsp

function goback() {
location.href = "//previous page";
}
<body onload="javascript_:goback()">
// INSERT to database
</body>

I am not sure if I did it in a right way. IF there is a better way please let me know

Use ajax for dynamic database insertions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.