I have radio buttons that disable and show a textbox on event.
Example:
On load
[ ] Option 1 [ ] Option 2
when i click option 2
[ ] Option 1 [ X ] Option 2
Textbox 1: [ ]
when i click option 1
[ X ] Option 1 [ ] Option 2
the textbox is disabled and hidden.
My problem is that when the user types something into a textbox and that textbox becomes disabled, the value is still sent to my database on submission. Is there a way i can clear this textbox value dynamically when Option 1 is selected? The things i can think would be to use the Events and run a function when option 1 is selected. But what is it that points to this textfield box?
Example:
On load
[ ] Option 1 [ ] Option 2
when i click option 2
[ ] Option 1 [ X ] Option 2
Textbox 1: [ ]
when i click option 1
[ X ] Option 1 [ ] Option 2
the textbox is disabled and hidden.
My problem is that when the user types something into a textbox and that textbox becomes disabled, the value is still sent to my database on submission. Is there a way i can clear this textbox value dynamically when Option 1 is selected? The things i can think would be to use the Events and run a function when option 1 is selected. But what is it that points to this textfield box?
Hi captainh,
Please double-check that the hidden text-boxes are disabled as a disabled element shouldn't Submit anything at all. (a readonly one will).
I generally also clear any elements when I hide them just to avoid old input data being inadvertently used in the wrong place.
Bob
Please double-check that the hidden text-boxes are disabled as a disabled element shouldn't Submit anything at all. (a readonly one will).
I generally also clear any elements when I hide them just to avoid old input data being inadvertently used in the wrong place.
Bob
http://i.imgur.com/IDTJVcu.png
As seen from this image. When i enter select others and locations appears and when i enter a value into it and select another value, the location box disppears. When i press submit, the location value is also submitted. As seen from my events image, i have it set on disabled when another value is selected.
Also, "I generally also clear any elements when I hide them..." How do i do this?
Thank you!
As seen from this image. When i enter select others and locations appears and when i enter a value into it and select another value, the location box disppears. When i press submit, the location value is also submitted. As seen from my events image, i have it set on disabled when another value is selected.
Also, "I generally also clear any elements when I hide them..." How do i do this?
Thank you!
This topic is locked and no more replies can be posted.