Forums

dropdown: 2 selected options (CF V4 RC 3.5)

emmexx 03 Dec, 2012
I don't know how to replicate this so I'm not sure that this report can be very useful.

I have a form with 3 dropdowns, 2 checkboxes, a submit button and a custom control full of php/html code.

2 of the dropdowns are similar with options like:

noSelection=
0=1st value
1=2nd value
...


and noSelection as the default selection.
Nonetheless 1st value kept beeing shown as the default selection but only in the 1st dropdown. After trying to change the default selection 2 or 3 times I checked the html Code of the form:

<select size="1" class="" title="" name="filter_status">
<option value="noSelection" selected="selected"></option>
<option value="0" selected="selected">1st value</option>
<option value="1">2nd value</option>
<option value="2">3rd value</option>
<option value="3">4th value</option>
</select>


I attach an image of the parameters of the element (here I translated in english the italian words).

I searched the forum for something regarding this problem but I didn't find anything, so I posted here.

bye
maxx

p.s. I deleted from the html code section of the form the wrong selected value, saved and the dropdown worked as expected. Then I opened the wizard, saved it and the wrong selected value is there again . ๐Ÿ˜Ÿ
GreyHead 03 Dec, 2012
Hi Maxx,

I'm not sure that I understand this :-(

Having an option with a value but no text like noSelection= doesn't make sense to me? What are you trying to achieve?

If you want to set a 'No selection' option then you can use the Show Empty box. If you put 'No selection' in there then ChronoForms will add a first option that is equivalent to =No selection that has text but not value so will return an empty string on submission.

I think that the first option is selected by default so if you want to set some other option as the default you can use the Selected box and add the equivalent value - like nessuno in there. (Or you can set a value in the $form->data array.)

I'm still not sure how you get two options shown as selected though :-(

Bob
emmexx 03 Dec, 2012

I'm not sure that I understand this :-(

Having an option with a value but no text like noSelection= doesn't make sense to me? What are you trying to achieve?



I use the dropdowns to filter data queried from a table. The blank option means no filter.

If you want to set a 'No selection' option then you can use the Show Empty box. If you put 'No selection' in there then ChronoForms will add a first option that is equivalent to =No selection that has text but not value so will return an empty string on submission.



Yes, I know. I suppose I tried that, it didn't work, so I added the noSelection= option.

[quote="GreyHead"]
I think that the first option is selected by default so if you want to set some other option as the default you can use the Selected box and add the equivalent value - like nessuno in there. (Or you can set a value in the $form->data array.)
[/quote]

I know but [color=#000080]nessuno[/color] is the 1st select. Probably I added that because the 2nd one kept showing up...

I'm still not sure how you get two options shown as selected though :-(



Me too... And why the 2nd dropdown works as expected? I mean, it is setup as the 1st one, only the name of the field is different. ๐Ÿคจ

I'll try the Show empty box again...

Thank you
maxx
emmexx 04 Dec, 2012
I tried the Show Empty option to no avail. ๐Ÿ˜Ÿ
I removed the empty option I had added as 1st value.
But when I save the 1st option has a selected tag:

<select class="" name="filter_status" title="" size="1">
<option value="">(no filter)</option>
<option selected="selected" value="0">1st value</option>
<option value="1">2nd value</option>
</select>


I have to remove it manually from the html code field.
I moved other controls before that one but nothing changed.

Very weird!

Whant can I do? Copy the form or create a new form?

Thank you
maxx
Max_admin 08 Dec, 2012
Hello,

You can't add an option with a value but without label, e.g:
noSelection=


There is a bug when you add a value="0", it will be auto selected, I will try to fix this in the next version, for now you may add a space to the "Show Empty" box and this will set the first option to an empty value and text.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.