More than one html radio button not getting value (1 Viewer)

megatronixs

Registered User.
Local time
Today, 11:01
Joined
Aug 17, 2012
Messages
719
Hi all,

I tried to create a survey based on html and Access database.
I found some great example and started to build from there.

I have this html page 2 text fields, one for first name, second for last name.
Then there is a radio button group where you have 5 choices and the submit button.

When I use only one radio button, it captures the value and it will be visible in the Access database, when I have all 5 radio buttons acctive, I only get "undefined" in the Access database.
I tried to find the answer, but seems that this kind of things are so rare that it took me long time to find the code so far I have.

The table (Customers) consist of:
Record_ID, set as autonumber
FirstName, set as text
Surname, set as text
question_1, set as text

This is the code I have so far:
Code:
<html>
<head>
<title>Pulse Survey</title>
<script language="JavaScript" >

function getSubmit()
{
var LastName;
var Firstn = names.value ;

var cn = new ActiveXObject("ADODB.Connection");
//here you must use forward slash to point strait
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/Users/Tom/Documents/clientDB.mdb";
var rs = new ActiveXObject("ADODB.Recordset");    
var SQL = "INSERT INTO Customers(FirstName, Surname, question_1)"
+ " VALUES ( '"+ names.value +"', '" + surname.value +"', '" + question_1.value +"')";
//var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'";

cn.Open(strConn);
rs.Open(SQL, cn);
surname.value = rs(0);
question_1.value = rs(1);
//alert(rs(0));
rs.Close();
cn.Close();


}

</script>
</head>
<body>

<br>
<br>
<br>

First Name <input type="text" name="names" />
<br>
<br>
Last Name <input type="text" name="surname" />

<br>
<br>
<br>

<fieldset class="radiogroup">
<legend>Do you like apples?</legend>

<br>

<INPUT TYPE="radio" name="question_1" VALUE="1">Strongly Agree
<INPUT TYPE="radio" name="question_1" VALUE="2">Agree
<INPUT TYPE="radio" name="question_1" VALUE="3">Neutral
<INPUT TYPE="radio" name="question_1" VALUE="4">Disagree
<INPUT TYPE="radio" name="question_1" VALUE="5">Strongly Disagree

</fieldset>
<br>
<br>

<input type="button" value="submit" onclick="getSubmit()">

</body>
</html>
Any one knowing where I go wrong?

I hope some one can learn from this too :)

Greetings.
 

Ranman256

Well-known member
Local time
Today, 06:01
Joined
Apr 9, 2015
Messages
4,339
Radio buttons MUST be inside a frame. The FRAME gets the value of the 5 buttons.
Each radio must be set to its own value.
The frame is bound to the field.
 

Users who are viewing this thread

Top Bottom