Forums

Disabled textfield with radiobox

eduardo.rj 24 Nov, 2012
Hi!

I'm trying to do the following operation:

I have three RadioBox,
and a textfield disabled.

Clicking on a particular "RadioButton", the "TextField" is enabled!

What is the possibility?
Using javascript?

Where do I include the Javascript code?
Some tutorial?

Thank you all
eduardo.rj 24 Nov, 2012
Exemple:

() Select 1
() Select 2
(x) Other Option

Another option here: -> my custom option
GreyHead 24 Nov, 2012
Hi eduardo.rj,

There is a FAQ here which describes how to do this with a checkbox. You'll need to change it a little to work with radio buttons.

Bob
eduardo.rj 24 Nov, 2012
Thank you.
Can I replace "Textarea" with "Fiedtext"?
The code accepts?
GreyHead 24 Nov, 2012
Hi eduardo.rj,

I expect so, try it and see.

Bob
eduardo.rj 25 Nov, 2012
Bob,

The code worked perfect with the "TextField".
Sorry but I'm a beginner in web development ...

Can you help me in this code?

I have a checkbox group with 03 options.
The last option enables this TextField.

May I suggest to the code?

Thanks for listening!
GreyHead 25 Nov, 2012
Hi eduardo.rj,

Sorry, please see this FAQ which is more helpful. I've just added a section using a Checkbox group.

Bob
eduardo.rj 25 Nov, 2012
Bob,

You are fantastic!
It was exactly what I needed ...
I'm going for a beer for you!
thank you!
eduardo.rj 26 Nov, 2012
Bob,
The code is ok.
Only a problem.
Selecting an simple option from the dropdown,
I get the parameter "{}".
 
Here's the code:

js:
window.addEvent('domready', function() {
  var select, other;
  select = $('choose_one');
  other = $('choose_one_other');
  switchOther();
  select.addEvent('change', switchOther);
  function switchOther() {
    if ( select.value == 'other' ) {
      other.disabled = false;
    } else {
      other.value = '';
      other.disabled = true;
    }
  }
});


html:
<table cellpadding="5" cellspacing="5" border="0">
	<tr>
		<td colspan='2'>
			Teste
		</td>
	</tr>
	<tr>
		<td>
			<strong>Selecione:</strong>
		</td>
		<td>
			{Selecione:}
		</td>
	</tr>
	<tr>
		<td>
			<strong>Outra:</strong>
		</td>
		<td>
			{outra}
		</td>
	</tr>
</table>


Debugger:


Data Array: 
Array
(
    [chronoform] => teste
    [event] => submit
    [format] => html
    [Itemid] => 133
    [option] => com_chronoforms
    [view] => form
    [Selecione:] => Opção 1
    [input_submit_12] => Submit
    [02d5981242dc29b9baf98ad0c0475d70] => 1
)
Validation Errors: 
Array
(
)
Debug Data
email
4
Result
An email has been SENT successfully from (Teste)test@test.com.br to test@test.com.br
Body
Teste
Selecione:	 Opção 1
Outra:	 {outra}  <-- The problem is here!



Attachments
array ( )


Email:

Teste
Selecione: Opção 1
Outra: {outra} <-- The problem is here!

How could receive an empty field instead of the parameter {}?

Thanks!
GreyHead 26 Nov, 2012
Hi eduardo.rj,

Please try removing the : from the input name [Selecione:] => Opção 1 - colons are not permitted in HTML input names or IDs.

Bob
eduardo.rj 26 Nov, 2012
Hi Bob,
I tried unsuccessfully several changes.
When the textbox is empty and disabled,
get the "{}" in my e-mail.

Data Array: 
Array
(
    [chronoform] => teste
    [event] => submit
    [format] => html
    [Itemid] => 133
    [option] => com_chronoforms
    [view] => form
    [Selecione] => Yes
    [input_submit_12] => Submit
    [c90bc9755788327a24d45816eb71f06a] => 1
)
Validation Errors: 
Array
(
)
Debug Data
email
4
Result

Body
Teste
Label Text	 Yes
Outro	 {}  <-- Here!



Attachments
array ( )
GreyHead 26 Nov, 2012
Hi eduardo.rj,

I don't know what the 'outra' variable is supposed to be if there is no result from the form there will be no value to put in the Email template.

Bob
GreyHead 26 Nov, 2012
Hi eduardo.rj,

Which version of ChronoForms are you using?
You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

Bob

PS You can attach images here using the Upload Attachment link under the message editor.
eduardo.rj 26 Nov, 2012
Hi Bob!

Joomla 2.5.8
Chronoforms V4_RC 3.5.1_J1.6
GreyHead 28 Nov, 2012
Hi eduardo.rj,

I was wondering if it was an older version from the images.

You should be able to set the 'ghost' option on the 'outro' element to make sure that there is a value in the form. If that doesn't work then it needs a little code after the form is submitted to check if there is a value and to add a blank one if $form->data['outro'] is not set.
<?php
if ( !isset($form->data['outro']) ) {
  $form->data['outro'] = '';
}
?>

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