We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

apwbe
apwbe asked
on
Medium Priority
237 Views
Last Modified: 2013-12-24
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.
Comment
Watch Question

Commented:
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>
Commented:
There must be some other bug with your code.  Can you show your code.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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>

Commented:
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>

Author

Commented:
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.