Link to home
Start Free TrialLog in
Avatar of apwbe
apwbeFlag for United States of America

asked on

CFINPUT selected has "/" in it and will not work.

I have a CFQUERY to a SQL Server database that  populates a drop down for a CFSELECT function on my web page form. I am trying to set the "SELECTED" to a value that contains an "/" (ie. Valid/Active). When setting the selected to an item that contains an "/" it will not display as selected. No problem with values not containing "/". The values containing the "/" will show up on the drop down, and can be selected from that drop down, I just can not get one of them to be the default selected.

There is probably a simple solution but I can not think of it right now.
Avatar of pmascari
pmascari
Flag of United States of America image

The browser is probably seeing the / and interpreting it to be the end of the tag.  If you must have the / in the HTML value, try moving the code to determine if it's selected outside of the tag itself like this:

<cfif value is "Valid/Active">
  <cfset OptionSelected = "SELECTED">
<cfelse>
   <cfset OptionSelected = "">
</cfif>

<cfoutput>
<cfselect name="mySelectTag" size="1">
<cfloop>
  <option value="Valid/Active" #OptionSelected#>Valid/Active
</cfloop>
</cfselected>
</cfoutput>
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

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
Avatar of apwbe

ASKER

pmascari

I have not been able to try your code yet. Will try and get to it sometime today.

mrichman

Hello my friend. Thanks for your past help on matters. Here is the CFSELECT code. Seems pretty direct. It just does not like the "/" in the data.

<CFQUERY NAME="Select_Status" DATASOURCE="liquor_lic_data">
SELECT      Status
FROM         dbo.Status_Domain
</CFQUERY>
.........

<cfoutput>
      <cfselect name="Status"
                      query="Select_Status"
                      value="Status"
                      selected="Valid/Active"
                      tabindex="8">
      </cfselect>
</cfoutput>
Avatar of mrichmon
mrichmon

Ah, okay it is the cfselct that doesn't like it.

I see 2 options.

1)
<cfoutput>
    <cfset Selected = "Valid/Active">
     <cfselect name="Status"
                    query="Select_Status"
                    value="Status"
                    selected="#Selected#"
                    tabindex="8">
     </cfselect>
</cfoutput>

But I dont' know if that will work.

2)
Use a regular html select isntead of cfselect.  cfselect does have some bugs as you can see from this problem.  Regular would look like:
<cfoutput>
     <select name="Status" tabindex="8">
           <cfloop query="Select_Status"><option value="#Status#" <cfif Status EQ "Valid/Active"> selected</cfif>>#Status#</option></cfloop>
     </select>
</cfoutput>
Avatar of apwbe

ASKER

mrichman,

I had to use the <select> instead of the <cfselect> and I also had to enter it by hand and not use the tag wizard in Homesite. For some reason the code created by the wizard (even though it looked exactly like the code I entered) would not work. I was able to figure it out using your <select> suggestion.

Thanks,

Warren