Skip to main content
Known Participant
November 29, 2006
Question

Multiple Select boxes in one form

  • November 29, 2006
  • 6 replies
  • 1122 views
Does anyone know if it is possible to have multiple select boxes inside one form? I have six different select boxes that are generated by six separate queries. The action page for all six select boxes is the same so I just want one submit button so users don't get confuse. I don't want to cluster up the page with submit buttons but I may resort to that option.

My problem is the select boxes generate a number and when that number is submitted I want to pass two other variables with it to the action page. I tried putting a "Form" tag around the 6 select boxes. Inside each select box I tried to add an "Input type="hidden"" and give thte name and values that I needed. That worked for the first select box but when I tried the second select box it used the hidden values for the first select box.

If anyone can help, I would greatly appreciate it. Or if you have any other suggestions I am open to any.

Thanks
    This topic has been closed for replies.

    6 replies

    December 2, 2006
    Check out qForms for making select controls based on a previous select control.
    Rcain37Author
    Known Participant
    November 30, 2006
    I did try isdefined and here is my code below. Should I write it in six different cfif's? I only want the user to select one box and hit the submit button. Here is the code I have for the isdefined function.

    If you want to take a look at what I am doing go to www.legis.state.wv.us/cainr/bill_status/bill_status.cfm. Select Resolution under the title "Select Bill Type". You will have to use something besides IE because the onclick funtion I use doesn't work in IE. So instead of using an onclick function, I have to use a Submit button and thats where I ran into this trouble.

    <cfif isdefined("form.srinput")>
    <cfset s = '#houseorig#'>
    <cfset r = '#billtype#'>
    <cfset input4 = form.srinput>

    <cfelseif isdefined("form.hrinput")>
    <cfset h = '#houseorig#'>
    <cfset r = '#billtype#'>
    <cfset input4 = form.hrinput>

    <cfelseif isdefined("form.scrinput")>
    <cfset s = '#houseorig#'>
    <cfset cr = '#billtype#'>
    <cfset input4 = form.scrinput>

    <cfelseif isdefined("form.hcrinput")>
    <cfset h = '#houseorig#'>
    <cfset cr = '#billtype#'>
    <cfset input4 = form.hcrinput>

    <cfelseif isdefined("form.sjrinput")>
    <cfset s = '#houseorig#'>
    <cfset jr = '#billtype#'>
    <cfset input4 = form.sjrinput>

    <cfelse>
    <cfset h = '#houseorig#'>
    <cfset jr = '#billtype#'>
    <cfset input4 = form.hjrinput>
    </cfif>
    Participating Frequently
    November 30, 2006
    You say that "I only want the user to select one box and hit the submit button.", but what happens if they select more than one? How are you restricting that, or are you just going to use the first box selected and not tell them?

    Phil
    Rcain37Author
    Known Participant
    November 30, 2006
    I thought that would be my next step to figure out.
    Rcain37Author
    Known Participant
    November 29, 2006
    Paross1,
    I wasn't thinking about that and you gave me a great idea. Here is how I changed my select boxes.

    <cfform action="Resolution_History.cfm?year=#year#&sessiontype=#sessiontype#&btype=res" name="form">
    <select name="SRINPUT">
    <option value="">SR
    <CFOUTPUT Query="findSR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>

    <select name="HRINPUT">
    <option value="">HR
    <CFOUTPUT Query="findHR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>

    <select name="SCRINPUT">
    <option value="">SCR
    <CFOUTPUT Query="findSCR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <br>
    <select name="HCRINPUT">
    <option value="">HCR
    <CFOUTPUT Query="findHCR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>

    <select name="SJRINPUT">
    <option value="">SJR
    <CFOUTPUT Query="findSJR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>

    <select name="HJRINPUT">
    <option value="">HJR
    <CFOUTPUT Query="findHJR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>

    <INPUT TYPE="Submit" VALUE="Submit" alt="submit button">
    </cfform>

    On the action page I need the below IF statement to work so it will set the variables. It isn't working at this time. Its not bringing the values of billnumber, houseorig or the billtype.

    Do you have any thoughts? I know it is close. I need to set all of the inputs to input4 to generate my queries.

    <cfif form.srinput gt 0>
    <cfset houseorig eq "s">
    <cfset billtype eq "r">
    <cfset srinput eq input4>

    <cfelseif form.hrinput gt 0>
    <cfset houseorig eq "h">
    <cfset billtype eq "r">
    <cfset hrinput eq input4>

    <cfelseif form.scrinput gt 0>
    <cfset houseorig eq "sc">
    <cfset billtype eq "r">
    <cfset scrinput eq input4>

    <cfelseif form.hcrinput gt 0>
    <cfset houseorig eq "hc">
    <cfset billtype eq "r">
    <cfset hcrinput eq input4>

    <cfelseif form.sjrinput gt 0>
    <cfset houseorig eq "sj">
    <cfset billtype eq "r">
    <cfset sjrinput eq input4>

    <cfelse>
    <cfset houseorig eq "hj">
    <cfset billtype eq "r">
    <cfset hjrinput eq input4>
    </cfif>

    Participating Frequently
    November 29, 2006
    You probably should check to see if each form variable IsDefined() before checking to see if it is GT 0 within your cfif. Also, why are you using cfelseif, since I am assuming that more than one select box can be selected?

    Pihl
    Rcain37Author
    Known Participant
    November 29, 2006
    Below is the code that I am trying to use. The first select box I need to pass the Input4, S, R all as separate variables. The second select box I need to pass Input4, H, R all as separate variables. Input4 are all numbers and I need to make each number distinct by adding the S, R or the H, R. I used an onclick function when I first created this page but I later found out it doesn't work in Internet Explorer. It worked great in other browsers though.


    <cfform action="Resolution_History.cfm?btype=res" name="form">
    <select name="INPUT4">
    <option value="">SR
    <CFOUTPUT Query="findSR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    <input type="Hidden" name="houseorig" value="s">
    <input type="Hidden" name="billtype" value="r">

    </select>

    <select name="INPUT4">
    <option value="">HR
    <CFOUTPUT Query="findHR"><Option Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    <input type="Hidden" name="houseorig" value="h">
    <input type="Hidden" name="billtype" value="r">
    </select>

    <input type="Hidden" name="year" value="<cfoutput>#year#</cfoutput>">
    <input type="Hidden" name="sessiontype" value="<cfoutput>#sessiontype#</cfoutput>">

    <INPUT TYPE="Submit" VALUE="Submit" alt="submit button">
    </cfform>
    Participating Frequently
    November 29, 2006
    For one thing, you need to use a differnent name for each of your SELECT tags, since this name is what is used on your action page. You are using INPUT4 for both. Plus, what do you expect the value of FORM.houseorig to be on your action page if someone opts to select more than one SELECT box?

    Phil
    Participating Frequently
    November 29, 2006
    Yes, it's possible. Post your code.
    Participating Frequently
    November 29, 2006
    The NAME that you use for each SELECT tag will be the FORM variable name on the action page to which you submit.

    Phil