Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Coldfusion radio button into to database

3443232 (TechnicalUser) (OP)
18 Dec 03 15:57
I am working in creating a form and add the information to my SQL database. www.tecnoclases.com/forma.cfm 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?

Thanks
hcanizares@yahoo.com
tlhawkins (Programmer)
18 Dec 03 16:33
Hello,

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:

<label>
<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#>
<cfelse>
  <!---   Go back and select Sexo --->
  <!---   Not actually possible seeing as you auto-select
          masculino but good practice --->
          
</cfif>

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
travis@cfm2asp.com
www.beachbumsoftware.com

3443232 (TechnicalUser) (OP)
18 Dec 03 17:18
SO this is what i understand
<cfif isDefined("form.sexo")>
  <cfset sexo = #form.sexo#>
<cfelse>
   WHAT DO I WRITE HERE?    
</cfif>

I BELIVE THAT NEXT IS MY INSERT TO DATABASE IF THE VISITOR IS FEMENINO OR MASCULINO

<CFINSERT DATASOURCE="datasoursename" TABLENAME="tablename" FORMFIELDS="SEXO">
My table in database is called "estudiante" and the field is "sexo"
ECAR (Programmer)
18 Dec 03 17:57
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.
Try:

<cfif isDefined("form.sexo")>
  <cfset sexo = #form.sexo#>
<cfelse>
   <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. --->
</cfif>

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

Hope This Helps!

Ecobb

"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

3443232 (TechnicalUser) (OP)
18 Dec 03 20:01
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
Henry
NetworkGuy101 (IS/IT--Management)
19 Dec 03 5:14
For your select box you can use something like this in a form tag:


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

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

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