Forums

Dropdown: send by mail Text and not Value. How?

monak83 14 Jun, 2012
Hi,
I'm using Joomla 2.5 and Chronoforms.
I have created a form where users insert some fields and select some options from a Select dropdown.
My problem is that I would send a mail with option text selected in the dropdown but chronoforms send to me the value of the option.
How can I send by email the text of my option?
I tried this code:

window.addEvent('domready', function(){
		$('select_1').addEvent('change', function(){
			this.getChildren().each(function(o){
				if (o.selected == true) {
					$('desc_select1').value = o.getText();
					var test=form.elemetns['desc_select1'].value;
					alert(test)
				}
			});
		});
	});

where select_1 is my select and desc_select1 is a text field hidden.
But dosen't works. why?
Regards
monak83
GreyHead 14 Jun, 2012
Hi monak83,

You could set up the options so that the text and the value are the same. Or I usually use a little code on the On Submit event to look up the text equivalent of any values I need to display.

You could modify your code to write the text to a hidden input but it's probably not worth the effort involved.

Bob
monak83 14 Jun, 2012
I can't use values equal to text because ibuse these the make some calculus.
I can i do to have on the email the text of dropdown selected?
GreyHead 15 Jun, 2012
Hi monak83,

Use a little PHP in a Custom Code action in the On Submit event to look up the text equivalent of any values.

Bob
monak83 15 Jun, 2012
can you post an example of this code?
I attach my select:

<select style="width:auto;" id="selec_1" size="1" class=" validate['required']" title="" container_id="0" name="banner" onchange="aggiorna_form(this.form)">
		<option value="0" selected="selected">Seleziona un Banner</option>
		<option value="1">TOP Categoria 3 mesi €69</option>
		<option value="2">TOP Categoria 6 mesi €99</option>
		<option value="3">TOP Categoria 12 mesi €149</option>
		<option value="4">TOP Home+Categoria 3 mesi €99</option>
		<option value="5">TOP Home+Categoria 6 mesi €149</option>
		<option value="6">TOP Home+Categoria 12 mesi €199</option>
</select>
GreyHead 18 Jun, 2012
Hi monak83,

Please try:
<?php
$banner_price_list = array(
  1 => 69,
  2 => 99,
  3 => 149,
  4 => 99,
  5 => 149,
  6 => 199
);
$form->data['banner_price'] = $banner_price_list[$form->data['banner']];
?>
And then {banner_price} in the email template.

Bob
dem0072 18 Jun, 2012
Ok, upon trying to input a custom element with that code I get the following php error:

Parse error: syntax error, unexpected T_DNUMBER, expecting ')' in /home/museum/public_html/administrator/components/com_chronoforms/form_actions/show_html/cfaction_show_html.php(124) : eval()'d code on line 57


The code I'm trying to use is:

<?php
$banner_price_list = array(
  Individual 50.00 => 50.00,
  Family 75.00 => 75.00,
  Smithsonian Sustainer 150.00 => 150.00,
  Contributor 250.00 => 250.00,
  Patron 500.00 => 500.00,
  1892 Club 1000.00 => 1000.00,
  Senior 30.00 => 30.00,
  Military 30.00 => 30.00,
  Educator 30.00 => 30.00,
  Artist 30.00 => 30.00,
  Dual Senior 60.00 => 60.00
);
$form->data['banner_price'] = $banner_price_list[$form->data['banner']];
?>


Is there any significant problems with it that you can see?
GreyHead 04 Apr, 2013
Hi lima_fil,

Thank you.

In PHP strings always need quotes - whether or not there are special characters.

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