getting optgroup values

Discussion in 'Programming' started by Jamie18, Oct 1, 2007.

  1. #1
    just wondering if there's a way to find out whether or not an option has been chosen from a certain optgroup......

    i can't think of a good way to explain it so i'll give you my scenario..

    i've got a drop down...

    
    <select id="page_types_list" multiple="multiple" size="10">
    	<optgroup id="groups" label="Groups">
    		<option value="page.name" <cfif isdefined("page.name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="407"></option>
    		<option value="page.web_url" <cfif isdefined("page.web_url")>selected="selected"</cfif>>Web URL</option>
    		<option value="page.description" <cfif isdefined("page.description")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="359"></option>
    		<option value="page.notes" <cfif isdefined("page.notes")>selected="selected"</cfif>>Notes</option>
    	</optgroup>
    	<optgroup id="contacts" label="Contacts">
    		<option value="contacts.contact_id" <cfif isdefined("contacts.contact_id")>selected="selected"</cfif>>ID</option>
    		<option value="contacts.first_name" <cfif isdefined("contacts.first_name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="408"></option>
    		<option value="contacts.last_name" <cfif isdefined("contacts.last_name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="409"></option>
    		<option value="contacts.title" <cfif isdefined("contacts.title")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="448"></option>
    		<option value="contacts.address" <cfif isdefined("contacts.address")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="335"></option>
    		<option value="contacts.city" <cfif isdefined("contacts.city")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="346"></option>
    		<option value="contacts.postal_code" <cfif isdefined("contacts.postal_code")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="429"></option>
    		<option value="contacts.province" <cfif isdefined("contacts.province")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="431"></option>
    		<option value="contacts.home_address" <cfif isdefined("contacts.home_address")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="437"> <CFMODULE template="#session.tagdir#text.cfm" ID="335"></option>
    		<option value="contacts.home_city" <cfif isdefined("contacts.home_city")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="437"> <CFMODULE template="#session.tagdir#text.cfm" ID="346"></option>
    		<option value="contacts.home_postal_code" <cfif isdefined("contacts.home_postal_code")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="437"> <CFMODULE template="#session.tagdir#text.cfm" ID="429"></option>
    		<option value="contacts.contact_description" <cfif isdefined("contacts.contact_description")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="359"></option>
    	</optgroup>
    	<optgroup id="telco" label="Telco">
    		<option value="telco.name" <cfif isdefined("telco.name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="407"></option>
    		<option value="telco.description" <cfif isdefined("telco.description")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="359"></option>
    		<option value="telco.notes" <cfif isdefined("telco.notes")>selected="selected"</cfif>>Notes</option>
    	</optgroup>
    	<optgroup id="message" label="Message">
    		<option value="message.name" <cfif isdefined("message.name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="407"></option>
    		<option value="message.emailtargets" <cfif isdefined("message.emailtargets")>selected="selected"</cfif>>E-mail Targets</option>
    	</optgroup>
    	<optgroup id="keyword" label="Keyword">
    		<option value="keyword.name" <cfif isdefined("keyword.name")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="407"></option>
    		<option value="keyword.description" <cfif isdefined("keyword.description")>selected="selected"</cfif>><CFMODULE template="#session.tagdir#text.cfm" ID="359"></option>
    	</optgroup>
    </select>
    
    Code (markup):
    these <CFMODULE template="#session.tagdir#text.cfm" ID="359"> are just used to retrieve the correct phrases in either french or english depending on the session variable..

    the select will be accompanied by a text input.. and on form submission i will be running sql statements to search the fields chosen in the select for the text in the text input..

    i need to do a query for each optgroup.. and what i'd like to do before attempting to run the queries is something like

    <cfif isdefined("page")>
    select name, blah
    from page
    where #chosen fields# like '%text input%'
    </cfif>

    where the isdefined("page") would tell me if an option has been selected from the page optgroup

    well anyways, i think that should be clear enough. any ideas?
     
    Jamie18, Oct 1, 2007 IP