I need to be able to loop through radio buttons and find the one that is selected and send that value into a query. The code I have is below. The JS function is something I just added, but I think it doesn't need to be a function. You can tinker with that, but leave most of the other code as is, because evrything else is working. The question mark below is where the value should go into the code. Thats where I'm stuck.
P.S. I removed all HTML and formatting just to so you can read it easier.
<SCRIPT LANGUAGE="JavaScript">
function GetRadioSelected()
{
var radiobuttons = document.getElementsByName
("TheRegio
n");
for (var x=0; x < radiobuttons.length; x++)
{
if (radiobuttons[x].checked)
{
var RadioSelected = radiobuttons[x].value;
}
}
}
</SCRIPT>
<CFQUERY NAME="GetCategories" DATASOURCE="#request.datas
ource#">
SELECT DISTINCT subcategory, Count(subcategory) AS SubcategoryCount
FROM tblSAS
WHERE reporttime > ###reportfrom###
GROUP BY subcategory
</CFQUERY>
<FORM NAME="SAS" ACTION="SAS.cfm?GetResults
" METHOD="post">
<CFOUTPUT>
<SELECT NAME="EventCategory" ID="EventCategory" SIZE="10" MULTIPLE>
<CFLOOP QUERY="GetCategories">
<OPTION VALUE="#subcategory#">#sub
category#<
/OPTION>
</CFLOOP>
</SELECT>
<BR>(hold ctrl key for multiple)
<CFLOOP QUERY="GetRegions">
<INPUT TYPE="Radio" NAME="TheRegion" VALUE="#Region#">
<IMG SRC="../../../images/#imgf
ile#" WIDTH="15" HEIGHT="15"> #Region#<BR>
</CFLOOP>
</CFOUTPUT>
<INPUT TYPE="Submit" NAME="Submit" VALUE="Search">
</FORM>
<CFQUERY NAME="GetSelectedResults" DBTYPE="query">
SELECT DISTINCT subcategory, subcategorycount
FROM GetCategories
WHERE subcategory IN (#PreserveSingleQuotes(The
Results)#)
<CFIF isDefined("TheRegion")>
AND (SELECT Region FROM GetRegions WHERE Region = '?')
</CFIF>
GROUP BY subcategory, subcategorycount
</CFQUERY>
Start Free Trial