• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Multiple Select inputs?

Multiple Select inputs? 16 years 11 months ago #108

I want to start off by saying I love the simplicity of this form. It could use a Documentation Guide as it took my a few tries to figure things out. But besides that, its great.

Now my question is, is there a way to have multiple Select inputs, based on the a previous Select input. For example, I am creating a form where a user can submit a business, organization, etc for a community listing. So my first select input has those categories. I would like a second select input to show up based on whichever category is selected in the first input.

To specify, a user can select from the first input:

Select input 1:
-Business
-Organiztion
-Restaurant
-etc.

Then if Business is accepted, the user can select from a second input:
-Bank
-Retail Store
-etc.
or if Restaurant was selecte, the user would have a different set of options:
-Steak
-Chinese
-Fast Food
-etc.

Let me know if this is confusing. Thanks in advance.
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #110

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Hm, haven't thought of this yet :)

But this can be performed by adding a custom javascript code. Basicly, after you create the select 1, name it Sel1 and add to it's attributes the code: onchange=\"this.changeSel2(this.selectedIndex)\", you create the second Select(that can be empty, name it Sel2). The javascript code should look like this(i did not tested it, so it may contain some js errors..):
function changeSel2(index){
MyOption = new Array();
MyOption[0] = new Array();
MyOption[0][0] = 'Bank';
MyOption[0][1] = 'Retail Store';
MyOption[0][2] = 'etc.';
 
MyOption[1] = new Array();
MyOption[1][0] = 'Steak';
MyOption[1][1] = 'Chinese';
MyOption[1][2] = 'Fast Food';
 
Sel2 = document.getElementById('Sel2');
//empty Sel2 items first
for(i=0;i<Sel2.options.length;i++){
Sel2.options[i] = null;
}
//populate with new items
for(i=0;i<MyOption[index].length;i++){
Sel2.options[i] = new Option(MyOption[index][i],MyOption[index][i]);
}
}
 

Hm, you made me curious LOL. I will try this form and let you know..
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #111

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
YES! I'm so happy :)

I managed to make it work. Here is my detailed solution:

In your Form Edit Screen, in the Form Style tab, add the following code after
{formfields}
	</table>
</form>
<script language=\"javascript\">
function changeSel2(index){
MyOption = new Array();
MyOption[0] = new Array();
MyOption[0][0] = 'Bank';
MyOption[0][1] = 'Retail Store';
MyOption[0][2] = 'etc.';
 
MyOption[1] = new Array();
MyOption[1][0] = 'Steak';
MyOption[1][1] = 'Chinese';
MyOption[1][2] = 'Fast Food';
 
Sel2 = document.getElementById('Sel2');
//empty Sel2 items first
for(i=0;i<Sel2.options.length;i++){
Sel2.options[i] = null;
}
//populate with new items
for(i=0;i<MyOption[index].length;i++){
Sel2.options[i] = new Option(MyOption[index][i],MyOption[index][i]);
}
}
</script>

Then create a new Select, name it Sel1, add to it's default value
Business|Business,Organization|Organization
and to it's additional attributes
onchange=\"changeSel2(this.selectedIndex)\"

Then add a second Select, name it Sel2, And leave it empty.

Let me know if it's working for you. I wil add this to the demo page also. It's way too cool. Thanks for your idea!
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #139

Thanks, this works great! Definitely one of the best Joomla! tools I have used so far. Bravo!
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #141

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Thanks! Your feedback means a lot to me.
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #153

  • ag2simal
  • ag2simal's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
Great work !
I realy works. But I do not need it :-)

Actualy, I do. But on some other way.

I need multiple check boxes after selection.
For example: on selection form you have values 1,2,3.
After you have sleected first value, it gives you 4 forms with check box.
If you select second one, it gives you 3 other forms with check box ... etc.

Is that possible?
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #155

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Hm, could you explain this better? I'm not sure i understood what you mean.
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #158

  • ag2simal
  • ag2simal's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
This code above means:
After you chose one option from selection 1 \"Business|Business,Organization|Organization\"
selection 2 gives you few \"subcategories\" (call them that way).

Well, I do not want selection 2.
I want 4 formfields after I select Business,
or 3 formfields after I select Organization

So, depending of selection 1, multiple different fields are given to chose after.<br><br>Post edited by: ag2simal, at: 2007/05/10 18:55
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #159

  • ag2simal
  • ag2simal's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
Maybe image will help
Attachments:
The administrator has disabled public write access.

Re:Multiple Select inputs? 16 years 11 months ago #162

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Yes, this can be done, but requires some javascript skills. Basicly the startpoint is to create all your final form(with all the fields), and hide Step2, Step3a. Then create a js function which on Step1 selection, loads & displays step2. Same procedure for step 3. I would do it, but i have to work on the 1.0.2 stable :(. I can assist you if you want.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!