Avatar of koila
koilaFlag for Australia asked on

Radio Buton - SQL DB Field Type - Checkbox DB Field Type.

I have this test form.  I would like to insert the data into a SQL Table.  I wold like to re-design the SQL Table.  Please help me on the Field type for YES  NO then for the checkbox.

I would like to create a SQL Table.

Into my design, for question 1 which field structure I should have for a radio button and how many field I should have for a checkbox button and type please.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<html>
<head>
<title>Form | </title>
</head>

<script type="text/javascript">
// checks buttons (radio, checkbox) - coursesweb.net
function checkButons(frm) {
var re = false;           // used to determine when a button is checked
var err = '';             // to store the errors

var question1 = frm.contactme;          // contains an array with all radio buttons "vegetable"

// create an Array in JSonn format with checkbox buttons
var question2 = [frm.CMTEE_PREF_NEW];

// traverse the radio buttons
// if one is checked sets re to true, and stops the iteration with "break"
for(var i=0; i<question1.length; i++) {
  if(question1[i].checked == true) {
    re = true;
    break;
  }
}

// if "re" is false means no radio button checked, add error in "err" 
if(re == false) err += '- You must check at least one vegetable';

// make "re" again False, and traverse the checkbox buttons
// if one is checked sets re to true, and stops the iteration with "break"
re = false
for(var i=0; i<question2.length; i++) {
  if(question2[i].checked == true) {
    re = true;
    break;
  }
}

// if "re" is false means no checkbox button checked, add error in "err" 
if (re == false) err += '\n - You must check at least one fruit';

// if "err" not empty, alert the error(s) and returns False to stop submitting form
if(err != "") {
  alert(err);
  return false;
}
else return re;
}
--></script>


<body>
<cfform id="f1" name="f1" action="confirmationn_e.cfm" method="POST" onsubmit="return checkButons(this);">
<p><font size=4><strong>Fill out this form: </strong> </font></p>

<p><br>
            <label for="strEmail"><strong><strong>1.</strong> If your skill set is suitable to other committees, </label>
          </p>
          <table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
            <tr>
              <td colspan="2" height="5" width="100%">
                <cfoutput><input type="radio" name="contactme" value="Yes">Yes &nbsp;
                
                <input type="radio" name="contactme" value="No">No<br></cfoutput>
                
                <p><br><label for="strEmail"><strong><strong>2.</strong> Which of the following types of committee would you prefer to serve on?</label>
          </p>
                    
          <table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
            <tr>
              <td colspan="2" height="5" width="100%">
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF1" value="POL">POL          <br>
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF2" value="SOP">SOP                <br>
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF3" value="EE">EE<br />
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF4" value="ADMIN" />ADMIN        <br>
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF5" value="TF">TF              <br>
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF6" value="ANY">ANY           <br>
                <input type="checkbox" name="CMTEE_PREF_NEW" id="CMTEE_PREF7" value="SP">SP
                </td>
            </tr>
          </table>
                   <p align="center">
            <input type="hidden" name="xaction" value="true">
            <input type="submit" value="Submit &raquo;">
            
            &nbsp;&nbsp;
            <input type="reset" value="Reset" name="B2">
          </p>
        </cfform>
</body>
</html>

Open in new window

MyTestFormLayout.jpg
Microsoft SQL ServerColdFusion Language

Avatar of undefined
Last Comment
koila

8/22/2022 - Mon
Jim Horn

>which field structure I should have for a radio button
radio buttons are normally used in an option group, which holds a single value of any type, and the user can select any one of those values by selecting the option button.
So ... the type depends on what the values are:  char, varchar, numeric, bit, whatever.

>how many field I should have for a checkbox button and type please.
checkbox = Values are either true or false = SQL bit column.  
This assumes that you don't want to entertain a NULL value.
ASKER
koila

Please review attached layout file and advise how many field I need and type.  I'm new
Jim Horn

Please work with expert comments given and respond in kind.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
koila

Please advice on my question.   Which type of fields I should select for the yes or no.   A boeilan?

How about the check box.  Should I have 6 fields.  For example.

Pol. What type I should have. When the user checked it should show 1 or 0 into the table?
ASKER CERTIFIED SOLUTION
Anthony Perkins

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Anthony Perkins

Oops this is a duplicate question see here:
https://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_28226128.html

I will repeat my comment there so that you can delete this question.
ASKER
koila

I've already accepted the solution that work for me.

thanks.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
koila

This is not a duplicate question, different technical requirements that I was looking for.

Thanks.