• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

using a radio button in cfmail / form.

Community Beginner ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

Hello;

This is a silly question, but I can't remember how to program in radio buttons for a cfmailer. I have 3 radio buttons, basically, I just need to know what the users choice was when they checked it off. The following is my radio buttons and what I have for code right now. But I'm not grabbing the proper variable, I also tried dumping a few diffrerent variables to see if I could get it.

<input name="type" type="radio" onClick="setVisibility('sub3', 'inline');setVisibility('sub4','none');setVisibility('sub5','none');" value='male' checked="checked"/>Magnets
<input type="radio" name="type" value='female' onClick="setVisibility('sub3', 'none');setVisibility('sub4','inline');setVisibility('sub5', 'none');"/>Paper Steel
<input type="radio" name="type" value='child' onClick="setVisibility('sub3', 'none');setVisibility('sub4','none');setVisibility('sub5', 'inline');"/> both

on my response page, I tried this:

<cfif form.type EQ "male">

if this was their choice, then this set of rules would apply

</cfif>

and so on for the other two choices. This isn't catching my buttons, what am I doing wrong? do I need to make a paramiter for the radio buttons before I can allow it to function? like this?

<cfparam name="FORM.type" default="">

then I can use my if statement? (that isn't working right now either)

here is what I'm trying to dump:

<cfdump var="#form.type#">
<cfabort>
</cfdump>

How do I do this? Can anyone help me?

TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

Make sure you specify the form's action and method, for example,

<form action="path_to_responsePage.cfm" method="post">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

I have all that. I was just posting the code for the radio bu

ttons.

my if statement isn't catching them. can you help me on that? What variables am I supposed to go after?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

Replace single quotes by double quotes. Change <input ... value='male' ...>, <input ... value='female' ...>, etc., to <input ... value="male" ...>, <input ... value="female" ...>, ... respectively.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

lol, I just tried fixing all that, and

even added an id field. I think it's my "if" statement now.

<cfif form.type EQ ('male')>

you get this

</cfif>

<cfif form.type EQ ('female')>

you get this

</cfif>

<cfif form.type EQ ('child')>

you get this

</cfif>

am I going after this wrong? I know a radio button is treated as a yes/no type input. I also know i can use it like this and still have it work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

I suspect that you have a problem in some portion of your code that you have not posted. To help debugging I suggest you create a simple test using two pages: input.cfm and action.cfm.  Get the most simple case working then add the javascript, css, and CF code to make your application work.

<!--- contents of input.cfm --->

<html>
<head>
     <title>Input</title>
</head>

<body>

     <form action="action.cfm" method="POST">
          Choose type: <br />
          <input name="type" type="radio" value="male" />     Male<br />
          <input name="type" type="radio" value="female" /> Female<br />
          <input type="submit" />
     </form>

</body>
</html>

<!--- content of action.cfm --->

<html>
<head>
     <title>Action</title>
</head>

<body>

     <cfif form.type eq "male">
          Type is male.
     <cfelseif form.type eq "female">
          Type is female.
     </cfif>
     
     Here is a cfdump of the form variables:<br />
     <cfdump var="#form#" />

</body>
     

</html>

Message was edited by: JR "Bob" Dobbs Added sample for action.cfm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

<cfif form.type EQ ('male')>

you get this

</cfif>

<cfif form.type EQ ('female')>

you get this

</cfif>

<cfif form.type EQ ('child')>

you get this

</cfif>

It should be without the brackets. What happens when you drop the brackets, like this

<cfif form.type EQ 'male'>

you get this

</cfif>

<cfif form.type EQ 'female'>

you get this

</cfif>

<cfif form.type EQ 'child'>

you get this

</cfif>

What happens when you omit the onClick attribute, and experiment with

<cfinput type="radio" name="type" value="male">
<cfinput type="radio" name="type" value="female">
<cfinput type="radio" name="type" value="child">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

I figured it out. It's because I'm using this as my submit button:

<cfinput type="image" name="Submit" validateat="onSubmit" validate="submitonce" style="cursor:Hand;" title="Submit Form" onMouseDown="javascript:this.src='img/submit.gif';" onMouseOver="javascript:this.src='img/submitOver.gif';" onMouseOut="javascript:this.src='img/submit.gif';" value="contact" src="img/submit.gif" alt="Contact Us" width="120" height="20"  border="0">

It doesn't like the image submit button.

So looks like this is out... unless someone knows a better way to get it to work using it. I couldn't even get the form to dump with this in. once I put in a real submit button, it all works.

thanks for the help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

LATEST

cfsetNewbie,

Does the cfinput of type="image" render an HTML input type="button" tag or a input type="submit" tag in the browser?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation