Copy link to clipboard
Copied
I'm fairly new at CF and I have a question about some functionality that I'm struggling with a bit.
I have a form with the following options field:
<option value="#getPages.Title#" <cfif variables.fieldValue EQ getPages.Title>checked="checked"</cfif>>#Trim(getPages.Title)#</option>
The value of #getPages.Title# is being populated from a database query call getPages. #getPages.Title# would output as a page title.
I have another value called #getPages.PageURL#.
My question is, is it possible to apply #getPages.PageURL# to #getPages.Title# so that when #getPages.Title# is output on a page it will be a link.
I've tried the below but it obviously didn't work.
<option value="<a href="#getPages.PageURL#">#getPages.Title#</a>" <cfif variables.fieldValue EQ getPages.Title>checked="checked"</cfif>>#Trim(getPages.Title)# </option>
Any help with this would be greatly appreciated.
Thanks,
Robert
Copy link to clipboard
Copied
The value in an OPTION element cannot contain arbitrary HTML. What you could do on the action page is look up the selected page in your database, then output the appropriate HTML there. If you want to avoid that database call, you could pass the URL as a hidden field, and populate that hidden field using JavaScript within the form.
Dave Watts, CTO, Fig Leaf Software