Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Coldfusion radio button into to database

Coldfusion radio button into to database

I am working in creating a form and add the information to my SQL database. for a text input  a use <CFINSERT DATASOURCE="datasoursename" TABLENAME="tablename" FORMFIELDS="formfield1,formfield2,">
I have a male and female radio button option  and I would like to add it in my database if the visitor is male or female but I do not know how.
I also have an upload button where visitor upload files. I know how to safe this file in a folder but I do not know how to record the path of the file into my database at the same time that is been uploaded.
Can someone help me?


RE: Coldfusion radio button into to database


I looked at your page and one thing I noticed is that your radio butons:  "masculino" and "femenino" don't exclude each other.  So a person could select both.  If you name them the same then you can only have one selected... which is probably what you're after.

so if you change it to:

<input name="sexo" type="radio" value="masculino" checked> masculino</label>
<label><input name="sexo" type="radio" value="femenino"> femenino</label>

then from your CFM you can do this:

<cfif isDefined("form.sexo")>
  <cfset sexo = #form.sexo#>
  <!---   Go back and select Sexo --->
  <!---   Not actually possible seeing as you auto-select
          masculino but good practice --->

then insert the variable sexo into the database.
That is of course assuming that you have a varchar (text) field setup in the database for "Sexo"

let me know if it works for you.  If not, give me some more info about the database field that you are using to hold the sex and I'll try to adjust it for you.

Travis Hawkins
BeachBum Software

RE: Coldfusion radio button into to database

SO this is what i understand
<cfif isDefined("form.sexo")>
  <cfset sexo = #form.sexo#>


My table in database is called "estudiante" and the field is "sexo"

RE: Coldfusion radio button into to database

Don't use <cfinsert> or <cfupdate> (ever), write you're own SQL Statements using <cfquery>.  <cfinsert> and <cfupdate> are unstable, and have been know to break and cause problems for no reason.

<cfif isDefined("form.sexo")>
  <cfset sexo = #form.sexo#>
   <cfset sexo = "Unknown">  
<!--- OR, here you could throw an error or force the user to go back and select a value or whatever else you want to happen. --->

<CFQUERY NAME="insert_SEXO" DATASOURCE="datasoursename">
INSERT INTO estudiante(sexo)

Hope This Helps!


"Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer." - Homer Simpson

RE: Coldfusion radio button into to database

Great, works perfect! Now I have two more problems.

I have a drop down "Nombre del Manual/curso" with many options that I pulled from the database. I would when they choose one of the options the option got recorded in the database.

The other problem is in the upload file input “Subir Manual” where visitor can upload file and get saved into a folder. I used <CFFILE> so the file get save into a folder that specified but I do not know how make the path of the file uploaded into the database as path link to the file.

Thanks so much

RE: Coldfusion radio button into to database

For your select box you can use something like this in a form tag:

<select name="selectname">
<cfoutput query="yourquery">
<option  value=">""</option>

And on your action page here is how it would be submitted:
<cfif IsDefined("FORM.selectname") AND #FORM.selectname# NEQ "">

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close