How to clear form input on a field by field basis

bgareth2 26 Aug, 2016
Hello,

I have been working on a form at this address http://www.gbglaw.org.uk/GBGLaw2/index.php?option=com_content&view=article&id=143&Itemid=289 under "alternative method" (not the items before it). What i'm looking to do is, when the user clicks "none/reset" - it clears any information in the relevant fields. For example, if somebody selected "Email", typed their Email address but then decided they wanted a response by post, i'd like to be able to clear what they had typed in the Email address box if they clicked "none/reset this section".

I also really would like to have the user be able to supply both their email address and postal details if they chose to.

Any help would be gratefully appreciated and thanks for your help :-)

Kind Regards,

Beanie.
bgareth2 26 Aug, 2016
Cheers for this Calculus00 of the automated robot world!

Hmmm, there must be an easier way surely and I don't really understand. I'm hoping a human could have some input to please? ๐Ÿ˜€
GreyHead 27 Aug, 2016
Hi Beanie,

If you want them to be able to do both then use separate CheckBox buttons for each option (you can give them all the same array name if you like) and use the Events tab in the CheckBox button element to show/hide the detail elements (you can put all of the address elements into a Container of type div and show/hide the whole container).

Bob
bgareth2 27 Aug, 2016
Thanks for this Bob, but how do I go about users starting by typing in their Email address, for example, and then thinking "oh crumbs, I don't want a response by Email, I want a response by post" and them somehow unclicking Email and the Email address inserted deliberately being cleared at the same time as there being an option to do both please? ๐Ÿ˜€
GreyHead 28 Aug, 2016
Hi bgareth2,

Hidden inputs aren't submitted - I think that is correct but you can easily check.

If not, you can do this with custom JavaScript to disable, empty and hide the unwanted elements.

Bob
bgareth2 02 Sep, 2016
Thanks for this. As I understand it, if the web viewer disables JS in their browser, this would either not work or make the whole form non functional - it would be confusing for the viewer to see the information still within the field, even after they change their mind, it would be nice if there was a simple way to clear the field. I suppose the hacky way is to make the box disappear but that still leaves the question there and is a tad messy :-(
GreyHead 02 Sep, 2016
Hi bgareth2,

You're right - about half the internet doesn't work if you disable JavaScript. Is this a real problem for your site?

I don't know of any other way to change the form display or settings in the browser.

Bob
This topic is locked and no more replies can be posted.