hello,
Quick question:
How do I set up an array of radio buttons the last of which will be a input from the user (usually named "Other") ?
Hi samoht,
You set up the array of radio buttons and add an extra text input field for the 'other' entry. It's a design question whether you include an 'other' button in the array - you will need to if you are setting any default values (having a button pre-checked).
You then need to handle the display logic in the OnSubmit code - that is looking to see if there is an 'other' value entered and using that in your database or email.
Bob
Hi samoht,
you will need a new field in the DB table for the other field, is this what you mean ?
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi samoht,
How you add the extra field is up to you. Most often designers add an extra text input with a label that says ' If other, please give details'.
You could add some clever JavaScript so that this field only displays once 'other' is selected; but it probably isn't necessary.
You also have to decide how to deal with the two fields in the back-end. You can simply keep them as two separate fields in the database table, or you could use some PHP to merge them. If you will ever need to re-display the form for editing then I'd keep all the raw data i.e. use two fields; otherwise you will have to write code to undo the merged values to re-create the form data.
Bob
Thanks guys!
You put me on the right track for sure.
I decided not to merge the two fields but just to have a separate text field for storage reasons. I made the calculation simplified by conditionals on the text field rather than the radio's. I also threw in some js to disable and clear the text field if any other radio was picked + code to check the "Other" radio if the text field has focus. It seems pretty foolproof and it stores and calculates well.
Thanks again!