Link to home
Start Free TrialLog in
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
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>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.
Avatar of koila

ASKER

Please review attached layout file and advise how many field I need and type.  I'm new
Please work with expert comments given and respond in kind.
Avatar of koila

ASKER

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
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops this is a duplicate question see here:
https://www.experts-exchange.com/questions/28226128/Mandatory-field-required-for-a-checkbox-and-radio-button.html

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

ASKER

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

thanks.
Avatar of koila

ASKER

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

Thanks.