Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button Value

Status
Not open for further replies.

ewylam

Programmer
Jan 25, 2005
16
US
I have been staring at this problem for the entire day now and I still can't figure it out. I think it is a simple solution but I got nothing. What I am trying to do is pass the value (Yes/No) of two seperate radio groups (FORM.MSEL_Delete, FORM.Input_Delete) on through the url to a new page when the form is submitted. The problem is the url always shows the answer as being "No". Any suggestions?

Thanks

here is my code:

<cfparam name="FORM.Exercise_Name" default="">
<cfparam name="FORM.MSEL_Delete" default="">
<cfparam name="FORM.Input_Delete" default="">
<cfparam name="FORM.MM_DeleteRecord" default="">

<cfif IsDefined("url.Current_Exercise_ID") AND #url.Current_Exercise_ID# NEQ "">
<cfquery name="Get_Exercise_Info" datasource="ExerciseWA">
SELECT * From Current_Exercises
WHERE Current_Exercise_ID = #url.Current_Exercise_ID#
</cfquery>
<cfelse>
<cfquery name="Get_Exercise_Info" datasource="ExerciseWA">
SELECT * From Current_Exercises
WHERE Exercise_Name = '#FORM.Exercise_Name#'
</cfquery>
</cfif>

<div align="center"><font color="#000066"><strong>Delete Exercise</strong></font></div>

<form name="Delete_Exercise_Form" method="post" action="./Delete_Temp.cfm?Current_Exercise_ID=
<cfoutput>#Get_Exercise_Info.Current_Exercise_ID#</cfoutput>
&Delete_MSEL=<cfif #FORM.MSEL_Delete# EQ "Yes">Yes<cfelse>No</cfif>
&Delete_Inputs=<cfif #FORM.Input_Delete# EQ "No">Yes<cfelse>No</cfif>">
<div align="center">
<table width="0" border="0" cellspacing="2" cellpadding="0">
<tr>
<td colspan="2"> <div align="center">
<label>Exercise Name: </label>
<input name="Exercise_Name" type="text" value="<cfif isdefined("Get_Exercise_Info.Exercise_Name")
AND #Get_Exercise_Info.Exercise_Name# NEQ ""><cfoutput>#Get_Exercise_Info.Exercise_Name#</cfoutput>
<cfelse></cfif>" size="25">
</div></td>
</tr>
<tr>
<td width="300"><div align="right">Delete MSEL and all Injects?</div></td>
<td width="300">
<input type="radio" name="MSEL_Delete" value='Yes'>
<label>Yes</label>
<input type="radio" name="MSEL_Delete" value='No' checked>
<label>No</label>
</td>
</tr>
<tr>
<td width="300"><div align="right">Delete Exercise Inputs, Attritions, and Outstanding Performers?</div></td>
<td width="300">
<input type="radio" name="Input_Delete" value='Yes'>
<label>Yes</label>
<input type="radio" name="Input_Delete" value='No' checked>
<label>No</label>
</td>
</tr>
</table>
<input name="Delete_Exercise" type="submit" value="Delete">
<input name="MM_DeleteRecord" type="hidden" value="Delete_Exercise_Form">
<br>
<font color="#FF0000"><strong>Please be sure you want to permanently delete the above items!!!
Once deleted they will not be recoverable!!!</strong></font>
</div>
</form>
 

You say that you are looking in the URL scope for the value of the fields. The fields that will be submitted from the form above will be in the Form scope, and not the url scope.

Try dumping the entire Form scope and see what that comes up with.

<CFDUMP VAR="#Form#">

Are you changing the value on the form before you submit the form? As you have the 'No' option on the radio buttons set as checked.

Hope this helps!

Tony
 
here's your problem (to elaborate on tony's answer)

Code:
...
[COLOR=red]<cfparam name="FORM.MSEL_Delete" default="">[/color]
...

<form name="Delete_Exercise_Form" method="post" action="./Delete_Temp.cfm?Current_Exercise_ID=
    <cfoutput>#Get_Exercise_Info.Current_Exercise_ID#</cfoutput>
    &[b]Delete_MSEL=<cfif #FORM.MSEL_Delete# EQ "Yes">Yes<cfelse>No</cfif>[/b]
    &Delete_Inputs=<cfif #FORM.Input_Delete# EQ "No">Yes<cfelse>No</cfif>">
when the form loads the value of form.Delete_MSEL is ""
so your statement that i bolded will always be "No". remember CF happens before it gets to the browser. change the radio button in the browser doesn't change the "No" in that way. once you submit the form your "yes" or "no" will then be in your "form.Delete_MSEL" variable.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Bombboy,

I skipped straight past that block!!! didn't even look at it!

Tony
 
I probably would have too except i wanted to see what the method was set to. if it's left out i believe IE defaults to "get" but netscape and others default to "post" that could have caused some confusion too. but the method was set to post so that wasn't the issue.

if your action page needs delete_MSEL in form or url depending on how the page is accessed what i would recommend is this in your action page.


<cfif isdefined("url.delete_MSEL")>
<cfset vDelete_MSEL = url.delete_MSEL>
<cfelse>
<cfset vDelete_MSEL = form.delete_MSEL>
</cfif>

that assumes that one will always be present. if not you'll want to elaborate on that to trap for instances where neither are defined.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Thank you for your quick responses. However I am still haveing problems. I did the DUMP and it shows that the (MSEL_Delete, Input_Delete) vaules are what I put in the form. However in the URL of the page that does the delete they still show as "No". I tried to delete the <cfparam> tags but I get an undefined error. Am I not understanding your solutions?
 
no you're not. :)

why can't you use form.delete_MSEL in your action page? after all, the rest of your data is in the form state...

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Thanks... I figured that out just before you sent you post. I just deleted all the url bs, and used the form. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top