Hi guys

Is there a way, where i can get two values from a option tag. I have form that needs to have values for it to display e.g

My form looks like the following.

<form method="post" name="frmone" action="Result.cfm" enctype="multipart/form-data">

<select name="selvalues" id="selvalues" class="input_style-1" id="selvalues" style="height:19px">
		<option value="1">Select Result</option>            
		<cfoutput query="qtest" >  
                <option value="#value1#">#value2#</option>
                </cfoutput>
</select> 
<input name="Check" type="submit" value="Check" />
</form>

Results page

<cfif not isdefined("Form.frmone")> 
    <cfset Form.frmone= "N"> 
</cfif> 
<CFQUERY NAME="results" DATASOURCE="db">
Select * From tbl
Where col1="#value1#" and col2="#value2#";
</CFQUERY>

Am trying to get value2 to be added in the select as one of the conditions please help.Value 1 is going through need value 2.Please help:'(

Recommended Answers

All 2 Replies

Is there a way, where i can get two values from a option tag

No. If there isn't a unique key you can use instead, you could concatenate the values into a single string. Pick a delimiter that doesn't occur in the data. Then use list functions to separate the values.

<!--- form --->
<option value="#value1#:#value2#">#value2#</option>

<!--- action page --->
<cfset value1 = getToken(form.selvalues, 1, ":")>
<cfset value2 = getToken(form.selvalues, 2, ":")>

Where col1="#value1#" and col2="#value2#"

Don't forget to use cfqueryparam to protect against sql injection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.