apwbe
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.
There is probably a simple solution but I can not think of it right now.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_dat a">
SELECT Status
FROM dbo.Status_Domain
</CFQUERY>
.........
<cfoutput>
<cfselect name="Status"
query="Select_Status"
value="Status"
selected="Valid/Active"
tabindex="8">
</cfselect>
</cfoutput>
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_dat
SELECT Status
FROM dbo.Status_Domain
</CFQUERY>
.........
<cfoutput>
<cfselect name="Status"
query="Select_Status"
value="Status"
selected="Valid/Active"
tabindex="8">
</cfselect>
</cfoutput>
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"><opt ion value="#Status#" <cfif Status EQ "Valid/Active"> selected</cfif>>#Status#</ option></c floop>
</select>
</cfoutput>
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"><opt
</select>
</cfoutput>
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
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
<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/Act
</cfloop>
</cfselected>
</cfoutput>